public TagsOperationParameters(Tags tag) { super(tag.getTagId()); _tag = tag; }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(VM_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(USER_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(GROUP_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(HOST_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(TEMPLATE_ID); return tags; } }
String getParentId(Tag tag) { return lookupTagByName(tag.getParent().getName()).getTagId().toString(); }
@Test public void testReadWriteDelete() throws Exception { final AtomicInteger counter = new AtomicInteger(); createAndRunThreadsForRunner(() -> { int val = counter.incrementAndGet(); Tags tag = createTag("tag" + val, "desc" + val); dao.save(tag); Tags fromDb = dao.get(tag.getTagId()); assertEquals(tag, fromDb); dao.remove(tag.getTagId()); fromDb = dao.get(tag.getTagId()); assertNull(fromDb); }, 100); }
/** * Ensures that all tags from the given list that have VMs associated with them are returned. */ @Test public void testGetAllVmTagsWithIds() { List<Tags> result = dao.getAllVmTagsWithIds(existingTag.getTagId().toString()); assertNotNull(result); assertFalse(result.isEmpty()); }
@Override public Tag get() { List<Tags> tags = getBackendCollection( Tags.class, QueryType.GetTagsByUserGroupId, new GetTagsByUserGroupIdParameters(groupId.toString()) ); for (Tags tag : tags) { if (tag.getTagId().equals(guid)) { return addLinks(populate(map(tag, null), tag)); } } return notFound(); }
@Override public Tag get() { List<Tags> tags = getBackendCollection( Tags.class, QueryType.GetTagsByVmId, new GetTagsByVmIdParameters(vmId.toString()) ); for (Tags tag : tags) { if (tag.getTagId().equals(guid)) { return addLinks(populate(map(tag, null), tag)); } } return notFound(); }
@Override public Tag get() { List<Tags> tags = getBackendCollection( Tags.class, QueryType.GetTagsByVdsId, new GetTagsByVdsIdParameters(hostId.toString()) ); for (Tags tag : tags) { if (tag.getTagId().equals(guid)) { return addLinks(populate(map(tag, null), tag)); } } return notFound(); }
/** * Ensures that getting a tag by id works as expected. */ @Test public void testGet() { Tags result = dao.get(existingTag.getTagId()); assertNotNull(result); assertEquals(existingTag, result); }
@Mapping(from = Tags.class, to = Tag.class) public static Tag map(Tags entity, Tag template) { Tag model = template != null ? template : new Tag(); model.setId(entity.getTagId().toString()); model.setName(entity.getTagName()); model.setDescription(entity.getDescription()); model.setParent(parent(entity)); return model; }
@Test public void testGetSameID() throws Exception { final Tags existing = dao.get(EXISTING_TAGS_IDS[0]); createAndRunThreadsForRunner(() -> { Tags result = dao.get(existing.getTagId()); assertEquals(existing, result); }, 100); }
/** * Ensures that saving a tag works as expected. */ @Test public void testSave() { dao.save(newTag); Tags result = dao.get(newTag.getTagId()); assertNotNull(result); assertEquals(newTag, result); }
/** * Ensures that updating a tag in the database works as expected. */ @Test public void testUpdate() { existingTag.setDescription("this is the updated description!"); dao.update(existingTag); Tags result = dao.get(existingTag.getTagId()); assertEquals(existingTag, result); }
@Override public void update(Tags tag) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("description", tag.getDescription()) .addValue("tag_id", tag.getTagId()) .addValue("tag_name", tag.getTagName()) .addValue("parent_id", tag.getParentId()) .addValue("readonly", tag.getIsReadonly()) .addValue("type", tag.getType()); getCallsHandler() .executeModification("Updatetags", parameterSource); }
protected CustomMapSqlParameterSource getParamsSource(Tags tag) { CustomMapSqlParameterSource paramsSource = new CustomMapSqlParameterSource(dbEngineDialect); paramsSource.addValue("description", tag.getDescription()) .addValue("tag_id", tag.getTagId()) .addValue("tag_name", tag.getTagName()) .addValue("parent_id", tag.getParentId()) .addValue("readonly", tag.getIsReadonly()) .addValue("type", tag.getType()); return paramsSource; }