Search in sources :

Example 1 with Bookmark

use of org.finos.waltz.model.bookmark.Bookmark in project waltz by khartec.

the class BookmarkServiceTest method bookmarkCanBeCreated.

@Test
public void bookmarkCanBeCreated() {
    EntityReference bookmarkedEntity = mkAppRef();
    Bookmark bookmark = createBookmark(bookmarkedEntity, "test bookmark");
    List<Bookmark> bookmarks = svc.findByReference(bookmarkedEntity);
    assertEquals(1, bookmarks.size());
    assertEquals(bookmark, first(bookmarks));
}
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 2 with Bookmark

use of org.finos.waltz.model.bookmark.Bookmark in project waltz by khartec.

the class BookmarkServiceTest method bookmarksCanBeCreated.

@Test
public void bookmarksCanBeCreated() {
    EntityReference bookmarkedEntity = mkAppRef();
    Bookmark bookmark1 = createBookmark(bookmarkedEntity, "test bookmark1");
    Bookmark bookmark2 = createBookmark(bookmarkedEntity, "test bookmark2");
    List<Bookmark> bookmarks = svc.findByReference(bookmarkedEntity);
    assertEquals(2, bookmarks.size());
    assertTrue(bookmarks.contains(bookmark1));
    assertTrue(bookmarks.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 3 with Bookmark

use of org.finos.waltz.model.bookmark.Bookmark in project waltz by khartec.

the class BookmarkServiceTest method bookmarksCanBeFoundBySelector.

@Test
public void bookmarksCanBeFoundBySelector() {
    EntityReference appRef1 = mkAppRef();
    EntityReference appRef2 = mkAppRef();
    createBookmark(appRef1, "a");
    createBookmark(appRef1, "b");
    createBookmark(appRef2, "c");
    Set<Bookmark> matches = svc.findByBookmarkIdSelector(mkOpts(appRef1, HierarchyQueryScope.EXACT));
    assertEquals(2, matches.size());
    assertEquals(asSet("a", "b"), SetUtilities.map(matches, m -> m.title().get()));
}
Also used : Bookmark(org.finos.waltz.model.bookmark.Bookmark) CollectionUtilities.first(org.finos.waltz.common.CollectionUtilities.first) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) BookmarkKindValue(org.finos.waltz.model.bookmark.BookmarkKindValue) Collections.emptySet(java.util.Collections.emptySet) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) EntityKind(org.finos.waltz.model.EntityKind) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) Test(org.junit.jupiter.api.Test) List(java.util.List) NameHelper.mkUserId(org.finos.waltz.integration_test.inmem.helpers.NameHelper.mkUserId) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) TestCase.assertTrue(junit.framework.TestCase.assertTrue) SetUtilities(org.finos.waltz.common.SetUtilities) EntityReference(org.finos.waltz.model.EntityReference) ImmutableBookmark(org.finos.waltz.model.bookmark.ImmutableBookmark) BookmarkService(org.finos.waltz.service.bookmark.BookmarkService) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) HierarchyQueryScope(org.finos.waltz.model.HierarchyQueryScope) 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 4 with Bookmark

use of org.finos.waltz.model.bookmark.Bookmark in project waltz by khartec.

the class BookmarksEndpoint method register.

@Override
public void register() {
    get(mkPath(BASE_URL, ":kind", ":id"), (request, response) -> {
        response.type(TYPE_JSON);
        EntityReference ref = getEntityReference(request);
        return bookmarkService.findByReference(ref);
    }, transformer);
    post(mkPath(BASE_URL), (request, response) -> {
        requireRole(userRoleService, request, SystemRole.BOOKMARK_EDITOR);
        response.type(TYPE_JSON);
        Bookmark bookmark = readBody(request, Bookmark.class);
        LOG.info("Saving bookmark: " + bookmark);
        boolean isUpdate = bookmark.id().isPresent();
        return isUpdate ? bookmarkService.update(bookmark, getUsername(request)) : bookmarkService.create(bookmark, getUsername(request));
    }, transformer);
    delete(mkPath(BASE_URL, ":id"), (request, response) -> {
        requireRole(userRoleService, request, SystemRole.BOOKMARK_EDITOR);
        response.type(TYPE_JSON);
        long bookmarkId = getId(request);
        Bookmark bookmark = bookmarkService.getById(bookmarkId);
        if (bookmark == null) {
            LOG.warn("Attempt made to delete non-existent bookmark: " + bookmarkId);
            return false;
        }
        LOG.info("Deleting bookmark: " + bookmark);
        return bookmarkService.deleteById(bookmark, getUsername(request));
    }, transformer);
}
Also used : Bookmark(org.finos.waltz.model.bookmark.Bookmark) EntityReference(org.finos.waltz.model.EntityReference)

Example 5 with Bookmark

use of org.finos.waltz.model.bookmark.Bookmark in project waltz by khartec.

the class BookmarkServiceTest method bookmarksCanReadById.

@Test
public void bookmarksCanReadById() {
    EntityReference bookmarkedEntity = mkAppRef();
    Bookmark bookmark1 = createBookmark(bookmarkedEntity, "test bookmark1");
    assertEquals(bookmark1, svc.getById(bookmark1.id().get()));
}
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)

Aggregations

EntityReference (org.finos.waltz.model.EntityReference)8 Bookmark (org.finos.waltz.model.bookmark.Bookmark)8 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)7 ImmutableBookmark (org.finos.waltz.model.bookmark.ImmutableBookmark)7 Test (org.junit.jupiter.api.Test)7 Collections.emptySet (java.util.Collections.emptySet)1 List (java.util.List)1 Set (java.util.Set)1 TestCase.assertTrue (junit.framework.TestCase.assertTrue)1 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)1 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)1 SetUtilities (org.finos.waltz.common.SetUtilities)1 SetUtilities.asSet (org.finos.waltz.common.SetUtilities.asSet)1 NameHelper.mkUserId (org.finos.waltz.integration_test.inmem.helpers.NameHelper.mkUserId)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)1 HierarchyQueryScope (org.finos.waltz.model.HierarchyQueryScope)1 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)1 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)1 BookmarkKindValue (org.finos.waltz.model.bookmark.BookmarkKindValue)1