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