/** * Add the tags field to the source map using the given list of tags. * * @param document * @param tags */ public void addTags(JsonObject document, Iterable<? extends Tag> tags) { List<String> tagUuids = new ArrayList<>(); List<String> tagNames = new ArrayList<>(); for (Tag tag : tags) { tagUuids.add(tag.getUuid()); tagNames.add(tag.getName()); } Map<String, List<String>> tagFields = new HashMap<>(); tagFields.put("uuid", tagUuids); tagFields.put("name", tagNames); document.put("tags", tagFields); }
public static Tag mockTag(String name, User user, TagFamily tagFamily, Project project) { Tag tag = mock(Tag.class); when(tag.getCreator()).thenReturn(user); when(tag.getCreationTimestamp()).thenReturn(TIMESTAMP_OLD); when(tag.getEditor()).thenReturn(user); when(tag.getLastEditedTimestamp()).thenReturn(TIMESTAMP_NEW); when(tag.getName()).thenReturn(name); when(tag.getUuid()).thenReturn(TAG_BLUE_UUID); when(tag.getTagFamily()).thenReturn(tagFamily); when(tag.getProject()).thenReturn(project); when(tag.getRolesWithPerm(GraphPermission.READ_PERM)).thenReturn(createEmptyTraversal()); when(tag.getElementVersion()).thenReturn(UUID_3); return tag; }
public TagResponseAssert matches(Tag tag) { assertGenericNode(tag, actual); // tag.setSchema(neo4jTemplate.fetch(tag.getSchema())); assertEquals(tag.getUuid(), actual.getUuid()); // assertEquals(tag.getSchema().getUuid(), restTag.getSchema().getUuid()); // assertEquals(tag.getSchema().getName(), restTag.getSchema().getSchemaName()); return this; }
/** * Transforms tags grouped by tag families * * @param document * @param tags */ private void addTagFamilies(JsonObject document, Iterable<? extends Tag> tags) { JsonObject familiesObject = new JsonObject(); for (Tag tag : tags) { TagFamily family = tag.getTagFamily(); JsonObject familyObject = familiesObject.getJsonObject(family.getName()); if (familyObject == null) { familyObject = new JsonObject(); familyObject.put("uuid", family.getUuid()); familyObject.put("tags", new JsonArray()); familiesObject.put(family.getName(), familyObject); } familyObject.getJsonArray("tags").add(new JsonObject().put("name", tag.getName()).put("uuid", tag.getUuid())); } document.put("tagFamilies", familiesObject); }
/** * Checks whether the given tag is listed within the node rest response. * * @param restNode * @param tag * @return */ public boolean contains(Tag tag) { assertNotNull(tag); assertNotNull(tag.getUuid()); assertNotNull(actual); assertNotEquals("There were not tags listed in the restNode.", 0, actual.getTags().size()); if (actual.getTags() == null) { return false; } for (TagReference tagRef : actual.getTags()) { if (tag.getUuid().equals(tagRef.getUuid())) { return true; } } return false; }
/** * Checks whether the given tag is listed within the branch rest response. * * @param tag * @return */ public boolean contains(Tag tag) { assertNotNull(tag); assertNotNull(tag.getUuid()); assertNotNull(actual); assertThat(actual.getTags()).as(descriptionText() + " tags").isNotNull().isNotEmpty(); for (TagReference tagRef : actual.getTags()) { if (tag.getUuid().equals(tagRef.getUuid())) { return true; } } return false; }
/** * Assert that the tag family was stored in the index. * * @param tag * @return Fluent API */ public DummySearchProviderAssert stored(Tag tag) { assertThat(actual).hasStore(Tag.composeIndexName(tag.getProject().getUuid()), Tag.composeDocumentId(tag.getUuid())); return this; }