diff --git a/calm-hub-ui/src/service/calm-service.tsx b/calm-hub-ui/src/service/calm-service.tsx index 4d8933aa5..f37d62d43 100644 --- a/calm-hub-ui/src/service/calm-service.tsx +++ b/calm-hub-ui/src/service/calm-service.tsx @@ -12,7 +12,9 @@ export async function fetchNamespaces(setNamespaces: (namespaces: string[]) => v headers, }); const data = await res.json(); - setNamespaces(data.values); + const values = Array.isArray(data?.values) ? data.values : []; + const namespaces = values.map((v: { name?: string }) => v?.name); + setNamespaces(namespaces); } catch (error) { console.error('Error fetching namespaces:', error); } diff --git a/calm-hub/mongo/init-mongo.js b/calm-hub/mongo/init-mongo.js index a417bf902..153634f4e 100644 --- a/calm-hub/mongo/init-mongo.js +++ b/calm-hub/mongo/init-mongo.js @@ -908,9 +908,9 @@ db.schemas.insertMany([ // Insert initial documents into the schem // Insert namespaces if they don't exist if (db.namespaces.countDocuments() === 0) { db.namespaces.insertMany([ - { namespace: "finos" }, - { namespace: "workshop" }, - { namespace: "traderx" } + { name: "finos", description: "FINOS namespace" }, + { name: "workshop", description: "Workshop namespace" }, + { name: "traderx", description: "TraderX namespace" } ]); print("Initialized namespaces: finos, workshop, traderx"); } else { diff --git a/calm-hub/src/integration-test/java/integration/MongoNamespaceIntegration.java b/calm-hub/src/integration-test/java/integration/MongoNamespaceIntegration.java index c0588727b..c6d401d6e 100644 --- a/calm-hub/src/integration-test/java/integration/MongoNamespaceIntegration.java +++ b/calm-hub/src/integration-test/java/integration/MongoNamespaceIntegration.java @@ -45,6 +45,7 @@ void end_to_end_confirmation_of_namespaces() { .when().get("/calm/namespaces") .then() .statusCode(200) - .body("values", hasItem("finos")); + .body("values.name", hasItem("finos")) + .body("values.description", hasItem("FINOS namespace")); } } diff --git a/calm-hub/src/integration-test/java/integration/MongoSetup.java b/calm-hub/src/integration-test/java/integration/MongoSetup.java index 88f04f792..40b557f34 100644 --- a/calm-hub/src/integration-test/java/integration/MongoSetup.java +++ b/calm-hub/src/integration-test/java/integration/MongoSetup.java @@ -14,7 +14,7 @@ public static void namespaceSetup(MongoDatabase database) { database.createCollection("namespaces"); // Insert multiple documents into 'namespaces' database.getCollection("namespaces").insertMany(Arrays.asList( - new Document("namespace", "finos") + new Document("name", "finos").append("description", "FINOS namespace") )); } } diff --git a/calm-hub/src/integration-test/java/integration/PermittedScopesIntegration.java b/calm-hub/src/integration-test/java/integration/PermittedScopesIntegration.java index 596eb705e..c4d2aad3e 100644 --- a/calm-hub/src/integration-test/java/integration/PermittedScopesIntegration.java +++ b/calm-hub/src/integration-test/java/integration/PermittedScopesIntegration.java @@ -159,7 +159,8 @@ void end_to_end_get_namespaces_with_valid_access_token(String scope) { .when().get("/calm/namespaces") .then() .statusCode(200) - .body("values", hasItem("finos")); + .body("values.name", hasItem("finos")) + .body("values.description", hasItem("FINOS namespace")); } @Test diff --git a/calm-hub/src/main/java/org/finos/calm/domain/NamespaceRequest.java b/calm-hub/src/main/java/org/finos/calm/domain/NamespaceRequest.java index 54f99927d..bf2324dd3 100644 --- a/calm-hub/src/main/java/org/finos/calm/domain/NamespaceRequest.java +++ b/calm-hub/src/main/java/org/finos/calm/domain/NamespaceRequest.java @@ -9,15 +9,25 @@ public class NamespaceRequest { @Pattern(regexp= NAMESPACE_REGEX, message = NAMESPACE_MESSAGE) - @NotNull(message = "Namespace must not be null") - @NotBlank(message = "Namespace must not be blank") - private String namespace; + @NotNull(message = "Name must not be null") + @NotBlank(message = "Name must not be blank") + private String name; - public String getNamespace() { - return namespace; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; } - public void setNamespace(String namespace) { - this.namespace = namespace; + public void setDescription(String description) { + this.description = description; } } diff --git a/calm-hub/src/main/java/org/finos/calm/domain/namespaces/NamespaceInfo.java b/calm-hub/src/main/java/org/finos/calm/domain/namespaces/NamespaceInfo.java new file mode 100644 index 000000000..77d1bd362 --- /dev/null +++ b/calm-hub/src/main/java/org/finos/calm/domain/namespaces/NamespaceInfo.java @@ -0,0 +1,27 @@ +package org.finos.calm.domain.namespaces; + +import jakarta.json.bind.annotation.JsonbPropertyOrder; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +@JsonbPropertyOrder({"name", "description"}) +public class NamespaceInfo { + @NotNull(message = "Name must not be null") + @NotBlank(message = "Name must not be blank") + private final String name; + private final String description; + + public NamespaceInfo(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + +} diff --git a/calm-hub/src/main/java/org/finos/calm/resources/NamespaceResource.java b/calm-hub/src/main/java/org/finos/calm/resources/NamespaceResource.java index 7291c02ff..26f02a965 100644 --- a/calm-hub/src/main/java/org/finos/calm/resources/NamespaceResource.java +++ b/calm-hub/src/main/java/org/finos/calm/resources/NamespaceResource.java @@ -13,6 +13,7 @@ import org.eclipse.microprofile.openapi.annotations.Operation; import org.finos.calm.domain.NamespaceRequest; import org.finos.calm.domain.ValueWrapper; +import org.finos.calm.domain.namespaces.NamespaceInfo; import org.finos.calm.security.CalmHubScopes; import org.finos.calm.security.PermittedScopes; import org.finos.calm.store.NamespaceStore; @@ -37,7 +38,7 @@ public NamespaceResource(NamespaceStore store) { ) @PermittedScopes({CalmHubScopes.ARCHITECTURES_ALL, CalmHubScopes.ARCHITECTURES_READ, CalmHubScopes.ADRS_ALL, CalmHubScopes.ADRS_READ}) - public ValueWrapper namespaces() { + public ValueWrapper namespaces() { return new ValueWrapper<>(namespaceStore.getNamespaces()); } @@ -51,16 +52,17 @@ public ValueWrapper namespaces() { @PermittedScopes({CalmHubScopes.ARCHITECTURES_ALL}) public Response createNamespace(@Valid @NotNull(message = "Request must not be null") NamespaceRequest request) throws URISyntaxException { - String namespace = request.getNamespace().trim(); + String name = request.getName().trim(); + String description = request.getDescription(); - if (namespaceStore.namespaceExists(namespace)) { + if (namespaceStore.namespaceExists(name)) { return Response.status(Response.Status.CONFLICT) .entity("{\"error\":\"Namespace already exists\"}") .build(); } - namespaceStore.createNamespace(namespace); - return Response.created(new URI("/calm/namespaces/" + namespace)).build(); + namespaceStore.createNamespace(name, description); + return Response.created(new URI("/calm/namespaces/" + name)).build(); } } \ No newline at end of file diff --git a/calm-hub/src/main/java/org/finos/calm/store/NamespaceStore.java b/calm-hub/src/main/java/org/finos/calm/store/NamespaceStore.java index d9118caab..c6fc5f128 100644 --- a/calm-hub/src/main/java/org/finos/calm/store/NamespaceStore.java +++ b/calm-hub/src/main/java/org/finos/calm/store/NamespaceStore.java @@ -1,9 +1,11 @@ package org.finos.calm.store; +import org.finos.calm.domain.namespaces.NamespaceInfo; + import java.util.List; public interface NamespaceStore { - List getNamespaces(); - boolean namespaceExists(String namespace); - void createNamespace(String namespace); + List getNamespaces(); + boolean namespaceExists(String namespaceName); + void createNamespace(String name, String description); } diff --git a/calm-hub/src/main/java/org/finos/calm/store/mongo/MongoNamespaceStore.java b/calm-hub/src/main/java/org/finos/calm/store/mongo/MongoNamespaceStore.java index fba29e258..e8b57123b 100644 --- a/calm-hub/src/main/java/org/finos/calm/store/mongo/MongoNamespaceStore.java +++ b/calm-hub/src/main/java/org/finos/calm/store/mongo/MongoNamespaceStore.java @@ -5,6 +5,7 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.inject.Typed; import org.bson.Document; +import org.finos.calm.domain.namespaces.NamespaceInfo; import org.finos.calm.store.NamespaceStore; import java.util.ArrayList; @@ -21,24 +22,25 @@ public MongoNamespaceStore(MongoDatabase database) { } @Override - public List getNamespaces() { - List namespaces = new ArrayList<>(); + public List getNamespaces() { + List namespaces = new ArrayList<>(); for (Document doc : namespaceCollection.find()) { - namespaces.add(doc.getString("namespace")); + namespaces.add(new NamespaceInfo(doc.getString("name"), doc.getString("description"))); } return namespaces; } @Override - public boolean namespaceExists(String namespace) { - Document query = new Document("namespace", namespace); + public boolean namespaceExists(String namespaceName) { + Document query = new Document("name", namespaceName); return namespaceCollection.find(query).first() != null; } @Override - public void createNamespace(String namespace) { - if (!namespaceExists(namespace)) { - Document namespaceDoc = new Document("namespace", namespace); + public void createNamespace(String name, String description) { + if (!namespaceExists(name)) { + Document namespaceDoc = new Document("name", name) + .append("description", description); namespaceCollection.insertOne(namespaceDoc); } } diff --git a/calm-hub/src/main/java/org/finos/calm/store/nitrite/NitriteNamespaceStore.java b/calm-hub/src/main/java/org/finos/calm/store/nitrite/NitriteNamespaceStore.java index fff55dd43..32bd5d24d 100644 --- a/calm-hub/src/main/java/org/finos/calm/store/nitrite/NitriteNamespaceStore.java +++ b/calm-hub/src/main/java/org/finos/calm/store/nitrite/NitriteNamespaceStore.java @@ -8,6 +8,7 @@ import org.dizitart.no2.collection.NitriteCollection; import org.dizitart.no2.filters.Filter; import org.finos.calm.config.StandaloneQualifier; +import org.finos.calm.domain.namespaces.NamespaceInfo; import org.finos.calm.store.NamespaceStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,7 +28,8 @@ public class NitriteNamespaceStore implements NamespaceStore { private static final Logger LOG = LoggerFactory.getLogger(NitriteNamespaceStore.class); private static final String COLLECTION_NAME = "namespaces"; - private static final String NAMESPACE_FIELD = "namespace"; + private static final String NAME_FIELD = "name"; + private static final String DESCRIPTION_FIELD = "description"; private final NitriteCollection namespaceCollection; @@ -38,33 +40,34 @@ public NitriteNamespaceStore(@StandaloneQualifier Nitrite db) { } @Override - public List getNamespaces() { - List namespaces = new ArrayList<>(); + public List getNamespaces() { + List namespaces = new ArrayList<>(); for (Document doc : namespaceCollection.find()) { - namespaces.add(doc.get(NAMESPACE_FIELD, String.class)); + namespaces.add(new NamespaceInfo(doc.get(NAME_FIELD, String.class), doc.get(DESCRIPTION_FIELD, String.class))); } LOG.debug("Retrieved {} namespaces from NitriteDB", namespaces.size()); return namespaces; } @Override - public boolean namespaceExists(String namespace) { - Filter filter = where(NAMESPACE_FIELD).eq(namespace); + public boolean namespaceExists(String namespaceName) { + Filter filter = where(NAME_FIELD).eq(namespaceName); Document doc = namespaceCollection.find(filter).firstOrNull(); boolean exists = doc != null; - LOG.debug("Namespace '{}' exists: {}", namespace, exists); + LOG.debug("Namespace '{}' exists: {}", namespaceName, exists); return exists; } @Override - public void createNamespace(String namespace) { - if (!namespaceExists(namespace)) { + public void createNamespace(String name, String description) { + if (!namespaceExists(name)) { Document namespaceDoc = Document.createDocument() - .put(NAMESPACE_FIELD, namespace); + .put(NAME_FIELD, name) + .put(DESCRIPTION_FIELD, description); namespaceCollection.insert(namespaceDoc); - LOG.info("Created namespace: {}", namespace); + LOG.info("Created namespace: {}", name); } else { - LOG.debug("Namespace '{}' already exists, skipping creation", namespace); + LOG.debug("Namespace '{}' already exists, skipping creation", name); } } } diff --git a/calm-hub/src/test/java/org/finos/calm/resources/TestNamespaceResourceShould.java b/calm-hub/src/test/java/org/finos/calm/resources/TestNamespaceResourceShould.java index 93208728e..61e39a4f8 100644 --- a/calm-hub/src/test/java/org/finos/calm/resources/TestNamespaceResourceShould.java +++ b/calm-hub/src/test/java/org/finos/calm/resources/TestNamespaceResourceShould.java @@ -2,6 +2,7 @@ import io.quarkus.test.InjectMock; import io.quarkus.test.junit.QuarkusTest; +import org.finos.calm.domain.namespaces.NamespaceInfo; import org.finos.calm.store.NamespaceStore; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -31,7 +32,6 @@ void return_empty_wrapper_when_no_namespaces_in_store() { .when() .get("/calm/namespaces") .then() - // Then: Verify the status code is 200 OK and the body contains the expected JSON .statusCode(200) .body(equalTo("{\"values\":[]}")); @@ -40,15 +40,17 @@ void return_empty_wrapper_when_no_namespaces_in_store() { @Test void return_namespaces_when_namespaces_in_store() { - when(namespaceStore.getNamespaces()).thenReturn(Arrays.asList("finos", "custom")); + when(namespaceStore.getNamespaces()).thenReturn(Arrays.asList( + new NamespaceInfo("finos","FINOS namespace"), + new NamespaceInfo("custom","custom ns") + )); given() .when() .get("/calm/namespaces") .then() - // Then: Verify the status code is 200 OK and the body contains the expected JSON .statusCode(200) - .body(equalTo("{\"values\":[\"finos\",\"custom\"]}")); + .body(equalTo("{\"values\":[{\"name\":\"finos\",\"description\":\"FINOS namespace\"},{\"name\":\"custom\",\"description\":\"custom ns\"}]}")); verify(namespaceStore, times(1)).getNamespaces(); } @@ -59,7 +61,7 @@ void create_namespace_successfully() { given() .contentType("application/json") - .body("{\"namespace\":\"test-namespace\"}") + .body("{\"name\":\"test-namespace\",\"description\":\"desc\"}") .when() .post("/calm/namespaces") .then() @@ -67,7 +69,7 @@ void create_namespace_successfully() { .header("Location", containsString("/calm/namespaces/test-namespace")); verify(namespaceStore).namespaceExists("test-namespace"); - verify(namespaceStore).createNamespace("test-namespace"); + verify(namespaceStore).createNamespace("test-namespace","desc"); } @Test @@ -79,32 +81,32 @@ void return_400_when_namespace_is_null() { .post("/calm/namespaces") .then() .statusCode(400) - .body(containsString("Namespace must not be null")); + .body(containsString("Name must not be null")); verify(namespaceStore, never()).namespaceExists(any()); - verify(namespaceStore, never()).createNamespace(any()); + verify(namespaceStore, never()).createNamespace(any(), any()); } @Test void return_400_when_namespace_is_empty() { given() .contentType("application/json") - .body("{\"namespace\":\"\"}") + .body("{\"name\":\"\"}") .when() .post("/calm/namespaces") .then() .statusCode(400) - .body(containsString("Namespace must not be blank")); + .body(containsString("Name must not be blank")); verify(namespaceStore, never()).namespaceExists(any()); - verify(namespaceStore, never()).createNamespace(any()); + verify(namespaceStore, never()).createNamespace(any(), any()); } @Test void return_400_when_namespace_contains_invalid_characters() { given() .contentType("application/json") - .body("{\"namespace\":\"test@namespace\"}") + .body("{\"name\":\"test@namespace\"}") .when() .post("/calm/namespaces") .then() @@ -112,7 +114,7 @@ void return_400_when_namespace_contains_invalid_characters() { .body(containsString(NAMESPACE_MESSAGE)); verify(namespaceStore, never()).namespaceExists(any()); - verify(namespaceStore, never()).createNamespace(any()); + verify(namespaceStore, never()).createNamespace(any(), any()); } @Test @@ -121,7 +123,7 @@ void return_409_when_namespace_already_exists() { given() .contentType("application/json") - .body("{\"namespace\":\"existing-namespace\"}") + .body("{\"name\":\"existing-namespace\"}") .when() .post("/calm/namespaces") .then() @@ -129,7 +131,7 @@ void return_409_when_namespace_already_exists() { .body(containsString("Namespace already exists")); verify(namespaceStore).namespaceExists("existing-namespace"); - verify(namespaceStore, never()).createNamespace(any()); + verify(namespaceStore, never()).createNamespace(any(), any()); } @Test @@ -143,6 +145,6 @@ void return_400_when_request_body_is_null() { .body(containsString("Request must not be null")); verify(namespaceStore, never()).namespaceExists(any()); - verify(namespaceStore, never()).createNamespace(any()); + verify(namespaceStore, never()).createNamespace(any(), any()); } } diff --git a/calm-hub/src/test/java/org/finos/calm/store/mongo/TestMongoNamespaceStoreShould.java b/calm-hub/src/test/java/org/finos/calm/store/mongo/TestMongoNamespaceStoreShould.java index fe28e2990..47d5a43fe 100644 --- a/calm-hub/src/test/java/org/finos/calm/store/mongo/TestMongoNamespaceStoreShould.java +++ b/calm-hub/src/test/java/org/finos/calm/store/mongo/TestMongoNamespaceStoreShould.java @@ -4,6 +4,7 @@ import io.quarkus.test.InjectMock; import io.quarkus.test.junit.QuarkusTest; import org.bson.Document; +import org.finos.calm.domain.namespaces.NamespaceInfo; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -45,7 +46,7 @@ void return_an_empty_list_when_no_namespaces_exist() { when(findIterable.iterator()).thenReturn(emptyCursor); when(namespaceCollection.find()).thenReturn(findIterable); - List namespaces = mongoNamespaceStore.getNamespaces(); + List namespaces = mongoNamespaceStore.getNamespaces(); assertThat(namespaces, is(empty())); verify(namespaceCollection).find(); } @@ -55,18 +56,19 @@ void return_list_of_namespaces() { DocumentFindIterable findIterable = Mockito.mock(DocumentFindIterable.class); DocumentMongoCursor cursor = Mockito.mock(DocumentMongoCursor.class); - Document doc1 = new Document("namespace", "finos"); - Document doc2 = new Document("namespace", "other"); + Document doc1 = new Document("name", "finos").append("description","FINOS namespace"); + Document doc2 = new Document("name", "other").append("description","other namespace"); - when(cursor.hasNext()).thenReturn(true, true, false); // 3 documents, then end + when(cursor.hasNext()).thenReturn(true, true, false); when(cursor.next()).thenReturn(doc1, doc2); when(findIterable.iterator()).thenReturn(cursor); when(namespaceCollection.find()).thenReturn(findIterable); - List namespaces = mongoNamespaceStore.getNamespaces(); - List expectedNamespaces = Arrays.asList("finos", "other"); + List namespaces = mongoNamespaceStore.getNamespaces(); + List expectedNamespaces = Arrays.asList(new NamespaceInfo("finos","FINOS namespace"), new NamespaceInfo("other","other namespace")); - assertThat(namespaces, is(expectedNamespaces)); + assertThat(namespaces.get(0).getName(), is(expectedNamespaces.get(0).getName())); + assertThat(namespaces.get(1).getName(), is(expectedNamespaces.get(1).getName())); } @Test @@ -78,7 +80,7 @@ void return_false_when_namespace_does_not_exist() { when(findIterable.first()).thenReturn(null); assertThat(mongoNamespaceStore.namespaceExists(namespace), is(false)); - verify(namespaceCollection).find(new Document("namespace", namespace)); + verify(namespaceCollection).find(new Document("name", namespace)); } @Test @@ -91,7 +93,7 @@ void return_true_when_namespace_exists() { when(findIterable.first()).thenReturn(documentMock); assertThat(mongoNamespaceStore.namespaceExists(namespace), is(true)); - verify(namespaceCollection).find(new Document("namespace", namespace)); + verify(namespaceCollection).find(new Document("name", namespace)); } @Test @@ -100,12 +102,12 @@ void create_namespace_when_it_does_not_exist() { String namespace = "new-namespace"; when(namespaceCollection.find(any(Document.class))).thenReturn(findIterable); - when(findIterable.first()).thenReturn(null); // namespace doesn't exist + when(findIterable.first()).thenReturn(null); - mongoNamespaceStore.createNamespace(namespace); + mongoNamespaceStore.createNamespace(namespace, "desc"); - verify(namespaceCollection).find(new Document("namespace", namespace)); - verify(namespaceCollection).insertOne(new Document("namespace", namespace)); + verify(namespaceCollection).find(new Document("name", namespace)); + verify(namespaceCollection).insertOne(new Document("name", namespace).append("description","desc")); } @Test @@ -115,11 +117,11 @@ void do_not_create_namespace_when_it_already_exists() { when(namespaceCollection.find(any(Document.class))).thenReturn(findIterable); Document documentMock = Mockito.mock(Document.class); - when(findIterable.first()).thenReturn(documentMock); // namespace exists + when(findIterable.first()).thenReturn(documentMock); - mongoNamespaceStore.createNamespace(namespace); + mongoNamespaceStore.createNamespace(namespace, "desc"); - verify(namespaceCollection).find(new Document("namespace", namespace)); + verify(namespaceCollection).find(new Document("name", namespace)); verify(namespaceCollection, Mockito.never()).insertOne(any(Document.class)); } diff --git a/calm-hub/src/test/java/org/finos/calm/store/nitrite/TestNitriteNamespaceStoreShould.java b/calm-hub/src/test/java/org/finos/calm/store/nitrite/TestNitriteNamespaceStoreShould.java index bf3567576..ac0a975f1 100644 --- a/calm-hub/src/test/java/org/finos/calm/store/nitrite/TestNitriteNamespaceStoreShould.java +++ b/calm-hub/src/test/java/org/finos/calm/store/nitrite/TestNitriteNamespaceStoreShould.java @@ -5,6 +5,7 @@ import org.dizitart.no2.collection.DocumentCursor; import org.dizitart.no2.collection.NitriteCollection; import org.dizitart.no2.filters.Filter; +import org.finos.calm.domain.namespaces.NamespaceInfo; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -41,8 +42,8 @@ public void setup() { @Test public void testGetNamespaces_whenNamespacesExist_returnsNamespacesList() { // Arrange - Document doc1 = Document.createDocument("namespace", "finos"); - Document doc2 = Document.createDocument("namespace", "workshop"); + Document doc1 = Document.createDocument("name", "finos").put("description","d1"); + Document doc2 = Document.createDocument("name", "workshop").put("description","d2"); List documents = Arrays.asList(doc1, doc2); DocumentCursor cursor = mock(DocumentCursor.class); @@ -50,11 +51,12 @@ public void testGetNamespaces_whenNamespacesExist_returnsNamespacesList() { when(mockCollection.find()).thenReturn(cursor); // Act - List result = namespaceStore.getNamespaces(); + List result = namespaceStore.getNamespaces(); // Assert assertThat(result, hasSize(2)); - assertThat(result, hasItems("finos", "workshop")); + assertThat(result.get(0).getName(), is("finos")); + assertThat(result.get(1).getName(), is("workshop")); } @Test @@ -67,7 +69,7 @@ public void testGetNamespaces_whenNoNamespacesExist_returnsEmptyList() { when(mockCollection.find()).thenReturn(cursor); // Act - List result = namespaceStore.getNamespaces(); + List result = namespaceStore.getNamespaces(); // Assert assertThat(result, is(empty())); @@ -76,7 +78,7 @@ public void testGetNamespaces_whenNoNamespacesExist_returnsEmptyList() { @Test public void testNamespaceExists_whenNamespaceExists_returnsTrue() { // Arrange - Document doc = Document.createDocument("namespace", "finos"); + Document doc = Document.createDocument("name", "finos"); DocumentCursor cursor = mock(DocumentCursor.class); when(cursor.firstOrNull()).thenReturn(doc); @@ -111,7 +113,7 @@ public void testCreateNamespace_whenNamespaceDoesNotExist_createsNamespace() { when(mockCollection.find(any(Filter.class))).thenReturn(cursor); // Act - namespaceStore.createNamespace("new-namespace"); + namespaceStore.createNamespace("new-namespace","desc"); // Assert verify(mockCollection).insert(any(Document.class)); @@ -120,13 +122,13 @@ public void testCreateNamespace_whenNamespaceDoesNotExist_createsNamespace() { @Test public void testCreateNamespace_whenNamespaceAlreadyExists_doesNotCreateDuplicate() { // Arrange - Document existingDoc = Document.createDocument("namespace", "existing-namespace"); + Document existingDoc = Document.createDocument("name", "existing-namespace"); DocumentCursor cursor = mock(DocumentCursor.class); when(cursor.firstOrNull()).thenReturn(existingDoc); when(mockCollection.find(any(Filter.class))).thenReturn(cursor); // Act - namespaceStore.createNamespace("existing-namespace"); + namespaceStore.createNamespace("existing-namespace","desc"); // Assert verify(mockCollection, never()).insert(any(Document.class)); diff --git a/package-lock.json b/package-lock.json index 5c05c61b5..d51b47999 100644 --- a/package-lock.json +++ b/package-lock.json @@ -569,7 +569,7 @@ }, "calm-plugins/vscode": { "name": "calm-vscode-plugin", - "version": "0.4.0", + "version": "0.4.1", "dependencies": { "@finos/calm-models": "file:../../calm-models", "@finos/calm-shared": "file:../../shared", @@ -1017,7 +1017,7 @@ }, "cli": { "name": "@finos/calm-cli", - "version": "1.30.0", + "version": "1.31.0", "license": "Apache-2.0", "dependencies": { "@apidevtools/json-schema-ref-parser": "^14.0.0",