/** * Transform a tag into a string of some kind. * @param tag The input tag. Must not be null. * @return The output string. Might be null. */ public String transform(Tag tag) { if (tag == null) { throw new NullPointerException("tag must not be null."); } switch (field) { case Name: return tag.getTagName(); case ID: return tag.getObjectIdentifier(); case Type: return tag.getType(); case Owner: return tag.getUserProfile().getUsername(); default: throw new IllegalStateException("Unknown field: " + field); } }
/** * Transform a tag into a string of some kind. * @param tag The input tag. Must not be null. * @return The output string. Might be null. */ public String transform(Tag tag) { if (tag == null) { throw new NullPointerException("tag must not be null."); } switch (field) { case Name: return tag.getTagName(); case ID: return tag.getObjectIdentifier(); case Type: return tag.getType(); case Owner: return tag.getUserProfile().getUsername(); default: throw new IllegalStateException("Unknown field: " + field); } }
private boolean tagExists(List<Tag> tags, String name, String taggedObject, String type, String userName) { for (Tag tag : tags) { if (tag.getTagName().equals(name) && tag.getObjectIdentifier().equals(taggedObject) && tag.getType().equals(type) && tag.getUserProfile().getUsername().equals(userName)) { return true; } } return false; } }
public void testAddTag() { Tag createdTag = manager.addTag("wowTag", "list1", "bag", "bob"); Tag retrievedTag = manager.getTags("wowTag", "list1", "bag", "bob").get(0); assertEquals(createdTag, retrievedTag); assertEquals(createdTag.getTagName(), "wowTag"); assertEquals(createdTag.getObjectIdentifier(), "list1"); assertEquals(createdTag.getType(), "bag"); assertEquals(createdTag.getUserProfile().getUsername(), "bob"); }
public void testAddWithProfile() throws Exception { Tag createdTag = manager.addTag("wowTag", "list1", "bag", bobProfile); Tag retrievedTag = manager.getTags("wowTag", "list1", "bag", "bob").get(0); assertEquals(createdTag, retrievedTag); assertEquals(createdTag.getTagName(), "wowTag"); assertEquals(createdTag.getObjectIdentifier(), "list1"); assertEquals(createdTag.getType(), "bag"); assertEquals(createdTag.getUserProfile().getUsername(), "bob"); }
&& actualTag.getObjectIdentifier().equals(expectedTag.getObjectIdentifier()) && actualTag.getType().equals(expectedTag.getType()) && "Unmarshall-1".equals(actualTag.getUserProfile().getUsername())) { continue ACTUAL;