Search in sources :

Example 91 with EntityReference

use of org.finos.waltz.model.EntityReference in project waltz by khartec.

the class BookmarkServiceTest method bookmarksCanBeUpdated.

@Test
public void bookmarksCanBeUpdated() {
    EntityReference bookmarkedEntity = mkAppRef();
    Bookmark bookmark = createBookmark(bookmarkedEntity, "test bookmark1");
    Long bookmarkId = bookmark.id().get();
    assertEquals(bookmark, svc.getById(bookmarkId));
    ImmutableBookmark updatedBookmark = ImmutableBookmark.copyOf(bookmark).withTitle("Updated").withLastUpdatedAt(DateTimeUtilities.today().atStartOfDay().plusHours(1));
    svc.update(updatedBookmark, "admin");
    assertEquals(updatedBookmark, svc.getById(bookmarkId));
}
Also used : Bookmark(org.finos.waltz.model.bookmark.Bookmark) ImmutableBookmark(org.finos.waltz.model.bookmark.ImmutableBookmark) ImmutableBookmark(org.finos.waltz.model.bookmark.ImmutableBookmark) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 92 with EntityReference

use of org.finos.waltz.model.EntityReference in project waltz by khartec.

the class BookmarkServiceTest method bookmarksCanBeRemovedBySelector.

@Test
public void bookmarksCanBeRemovedBySelector() {
    EntityReference appRef1 = mkAppRef();
    EntityReference appRef2 = mkAppRef();
    IdSelectionOptions a1_opts = mkOpts(appRef1, HierarchyQueryScope.EXACT);
    IdSelectionOptions a2_opts = mkOpts(appRef2, HierarchyQueryScope.EXACT);
    createBookmark(appRef1, "a");
    createBookmark(appRef1, "b");
    createBookmark(appRef2, "c");
    int numRemoved = svc.deleteByBookmarkIdSelector(a1_opts);
    assertEquals(2, numRemoved, "both app1 bookmarks should have been removed");
    assertEquals(emptySet(), svc.findByBookmarkIdSelector(a1_opts), "no app1 bookmarks should be left");
    assertEquals(1, svc.findByBookmarkIdSelector(a2_opts).size(), "the app2 bookmark should remain");
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 93 with EntityReference

use of org.finos.waltz.model.EntityReference in project waltz by khartec.

the class BookmarkServiceTest method bookmarksAreAttachedToSpecificEntities.

@Test
public void bookmarksAreAttachedToSpecificEntities() {
    EntityReference bookmarkedEntity = mkAppRef();
    EntityReference anotherBookmarkedEntity = mkAppRef();
    Bookmark bookmark1 = createBookmark(bookmarkedEntity, "test bookmark1");
    Bookmark bookmark2 = createBookmark(anotherBookmarkedEntity, "test bookmark2");
    List<Bookmark> bookmarksForFirstEntity = svc.findByReference(bookmarkedEntity);
    assertEquals(1, bookmarksForFirstEntity.size());
    assertTrue(bookmarksForFirstEntity.contains(bookmark1));
    List<Bookmark> bookmarksForSecondEntity = svc.findByReference(anotherBookmarkedEntity);
    assertEquals(1, bookmarksForSecondEntity.size());
    assertTrue(bookmarksForSecondEntity.contains(bookmark2));
}
Also used : Bookmark(org.finos.waltz.model.bookmark.Bookmark) ImmutableBookmark(org.finos.waltz.model.bookmark.ImmutableBookmark) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 94 with EntityReference

use of org.finos.waltz.model.EntityReference in project waltz by khartec.

the class DataTypeDecoratorServiceTest method findSuggestedByEntityRef.

@Test
public void findSuggestedByEntityRef() {
    String username = mkName("updateDecorators");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    assertThrows(UnsupportedOperationException.class, () -> dtdSvc.findSuggestedByEntityRef(a), "Throw exception if not a logical data flow or physical spec");
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    LogicalFlow flow = lfHelper.createLogicalFlow(a, b);
    Collection<DataType> suggestedWhenNoFlows = dtdSvc.findSuggestedByEntityRef(flow.entityReference());
    assertEquals(emptyList(), suggestedWhenNoFlows, "If no flows associated to entity should return empty list");
    EntityReference c = appHelper.createNewApp("b", ouIds.a1);
    LogicalFlow flow2 = lfHelper.createLogicalFlow(b, c);
    Long dtId = dataTypeHelper.createDataType("updateDecorators");
    Long dtId2 = dataTypeHelper.createDataType("updateDecorators2");
    dtdSvc.updateDecorators(username, flow.entityReference(), asSet(dtId), emptySet());
    dtdSvc.updateDecorators(username, flow2.entityReference(), asSet(dtId, dtId2), emptySet());
    Collection<DataType> suggestedWhenUpstream = dtdSvc.findSuggestedByEntityRef(flow.entityReference());
    assertEquals(asSet(dtId), map(suggestedWhenUpstream, d -> d.id().get()), "Should return suggested data types based on the upstream app");
    Collection<DataType> suggestedWhenSrcHasUpstreamAndDownStream = dtdSvc.findSuggestedByEntityRef(flow2.entityReference());
    assertEquals(asSet(dtId, dtId2), map(suggestedWhenSrcHasUpstreamAndDownStream, d -> d.id().get()), "Should return suggested data types based on up and down stream flows on the upstream app");
    Long specId = psHelper.createPhysicalSpec(a, "updateDecorators");
    pfHelper.createPhysicalFlow(flow.entityReference().id(), specId, "updateDecorators");
    Collection<DataType> suggestedForPsWhenUpstream = dtdSvc.findSuggestedByEntityRef(mkRef(EntityKind.PHYSICAL_SPECIFICATION, specId));
    assertEquals(asSet(dtId), map(suggestedForPsWhenUpstream, d -> d.id().get()), "Should return suggested data types based on the upstream app");
    Long specId2 = psHelper.createPhysicalSpec(a, "updateDecorators");
    Collection<DataType> specNotInvolvedInFlows = dtdSvc.findSuggestedByEntityRef(mkRef(EntityKind.PHYSICAL_SPECIFICATION, specId2));
    assertEquals(emptyList(), specNotInvolvedInFlows, "Spec not involved in flows should return empty list");
}
Also used : org.finos.waltz.integration_test.inmem.helpers(org.finos.waltz.integration_test.inmem.helpers) CollectionUtilities.first(org.finos.waltz.common.CollectionUtilities.first) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Collections.emptySet(java.util.Collections.emptySet) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collections.emptyList(java.util.Collections.emptyList) EntityKind(org.finos.waltz.model.EntityKind) Collection(java.util.Collection) DataTypeUsageCharacteristics(org.finos.waltz.model.datatype.DataTypeUsageCharacteristics) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) Autowired(org.springframework.beans.factory.annotation.Autowired) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) DataTypeDecoratorService(org.finos.waltz.service.data_type.DataTypeDecoratorService) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) DataType(org.finos.waltz.model.datatype.DataType) Test(org.junit.jupiter.api.Test) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) List(java.util.List) NameHelper.mkName(org.finos.waltz.integration_test.inmem.helpers.NameHelper.mkName) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) Assertions(org.junit.jupiter.api.Assertions) EntityReference(org.finos.waltz.model.EntityReference) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) DataType(org.finos.waltz.model.datatype.DataType) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 95 with EntityReference

use of org.finos.waltz.model.EntityReference in project waltz by khartec.

the class DataTypeDecoratorServiceTest method findByFlowIds.

@Test
public void findByFlowIds() {
    Collection<DataTypeDecorator> lfDecs = dtdSvc.findByFlowIds(emptyList(), EntityKind.LOGICAL_DATA_FLOW);
    Collection<DataTypeDecorator> psDecs = dtdSvc.findByFlowIds(emptyList(), EntityKind.PHYSICAL_SPECIFICATION);
    assertEquals(emptyList(), lfDecs, "If empty id list provided returns empty list");
    assertEquals(emptyList(), psDecs, "If empty id list provided returns empty list");
    Collection<DataTypeDecorator> invalidId = dtdSvc.findByFlowIds(asList(-1L), EntityKind.LOGICAL_DATA_FLOW);
    assertEquals(emptyList(), invalidId, "If flow id doesn't exist returns empty list");
    assertThrows(IllegalArgumentException.class, () -> dtdSvc.findByFlowIds(asList(-1L), EntityKind.APPLICATION), "If unsupported kind id throws exception");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    LogicalFlow flow = lfHelper.createLogicalFlow(a, b);
    Collection<DataTypeDecorator> withNoDecorators = dtdSvc.findByFlowIds(asList(flow.entityReference().id()), EntityKind.LOGICAL_DATA_FLOW);
    assertEquals(emptyList(), withNoDecorators, "flow has no decorators");
    Long dtId = dataTypeHelper.createDataType("findByFlowIds");
    String username = mkName("findByFlowIds");
    dtdSvc.updateDecorators(username, flow.entityReference(), asSet(dtId), emptySet());
    Collection<DataTypeDecorator> flowDecorators = dtdSvc.findByFlowIds(asList(flow.entityReference().id()), EntityKind.LOGICAL_DATA_FLOW);
    assertEquals(1, flowDecorators.size(), "Flow with one datatype associated returns a set with one decorator");
    assertEquals(dtId, Long.valueOf(first(flowDecorators).dataTypeId()), "Returns the correct datatype id on the decorator");
    Long dtId2 = dataTypeHelper.createDataType("findByFlowIds2");
    Long dtId3 = dataTypeHelper.createDataType("findByFlowIds3");
    dtdSvc.updateDecorators(username, flow.entityReference(), asSet(dtId2, dtId3), emptySet());
    Collection<DataTypeDecorator> multipleDecorators = dtdSvc.findByFlowIds(asList(flow.entityReference().id()), EntityKind.LOGICAL_DATA_FLOW);
    assertEquals(3, multipleDecorators.size());
    assertEquals(asSet(dtId, dtId2, dtId3), map(multipleDecorators, DataTypeDecorator::dataTypeId), "Returns all decorators for the flow");
    assertThrows(UnsupportedOperationException.class, () -> dtdSvc.findByFlowIds(asSet(dtId), EntityKind.PHYSICAL_SPECIFICATION), "Find by flow ids is only supported for logical flows");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

EntityReference (org.finos.waltz.model.EntityReference)114 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)55 Test (org.junit.jupiter.api.Test)55 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)40 EntityKind (org.finos.waltz.model.EntityKind)23 List (java.util.List)21 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)19 Autowired (org.springframework.beans.factory.annotation.Autowired)17 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)16 Set (java.util.Set)14 Collection (java.util.Collection)13 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)13 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)10 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)9 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)8 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)8 Bookmark (org.finos.waltz.model.bookmark.Bookmark)8 Collections.emptyList (java.util.Collections.emptyList)7 Collectors (java.util.stream.Collectors)7 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)7