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));
}
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");
}
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));
}
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");
}
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");
}
Aggregations