Search in sources :

Example 36 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceTest method testCreateTagLowerCaseParameters.

@Test
public void testCreateTagLowerCaseParameters() {
    // Create and persist a tag type entity.
    tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create a tag using lowercase input parameters.
    Tag resultTag = tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE.toLowerCase(), TAG_CODE.toLowerCase()), TAG_DISPLAY_NAME.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toLowerCase(), NO_PARENT_TAG_KEY));
    // Get the tag entity.
    TagEntity tagEntity = tagDao.getTagByKey(tagKey);
    assertNotNull(tagEntity);
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), new TagKey(TAG_TYPE, TAG_CODE.toLowerCase()), TAG_DISPLAY_NAME.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toLowerCase(), tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), resultTag);
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) TagKey(org.finra.herd.model.api.xml.TagKey) TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Example 37 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagUpdate.

@Test
public void testUpdateSearchIndexDocumentTagUpdate() throws Exception {
    List<TagEntity> tagEntityList = new ArrayList<>();
    TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_DESCRIPTION);
    TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE_2, TAG_CODE_2), TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2);
    tagEntityList.add(tagEntity1);
    tagEntityList.add(tagEntity2);
    List<Integer> tagIds = new ArrayList<>();
    tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId()));
    // Create a document on the search index
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("DOCUMENT_TYPE");
    when(tagDao.getTagsByIds(tagIds)).thenReturn(tagEntityList);
    when(tagHelper.safeObjectMapperWriteValueAsString(any(TagEntity.class))).thenReturn("JSON_STRING");
    // Call the method under test
    tagService.updateSearchIndexDocumentTag(searchIndexUpdateDto);
    // Verify the calls to external methods
    verify(configurationHelper, times(1)).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(tagDao, times(1)).getTagsByIds(tagIds);
    verify(tagHelper, times(2)).safeObjectMapperWriteValueAsString(any(TagEntity.class));
    verify(indexFunctionsDao, times(1)).updateIndexDocuments(any(), any(), any());
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) ArrayList(java.util.ArrayList) TagKey(org.finra.herd.model.api.xml.TagKey) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Test(org.junit.Test)

Example 38 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagDelete.

@Test
public void testUpdateSearchIndexDocumentTagDelete() throws Exception {
    List<TagEntity> tagEntityList = new ArrayList<>();
    TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_DESCRIPTION);
    TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE_2, TAG_CODE_2), TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2);
    tagEntityList.add(tagEntity1);
    tagEntityList.add(tagEntity2);
    List<Integer> tagIds = new ArrayList<>();
    tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId()));
    // Delete from the search index
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, SEARCH_INDEX_UPDATE_TYPE_DELETE);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("DOCUMENT_TYPE");
    doNothing().when(indexFunctionsDao).deleteIndexDocuments(any(), any(), any());
    // Call the method under test
    tagService.updateSearchIndexDocumentTag(searchIndexUpdateDto);
    // Verify the calls to external methods
    verify(configurationHelper, times(1)).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(indexFunctionsDao, times(1)).deleteIndexDocuments(any(), any(), any());
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) ArrayList(java.util.ArrayList) TagKey(org.finra.herd.model.api.xml.TagKey) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Test(org.junit.Test)

Example 39 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagCreateEmpty.

@Test
public void testUpdateSearchIndexDocumentTagCreateEmpty() throws Exception {
    List<TagEntity> tagEntityList = new ArrayList<>();
    TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_DESCRIPTION);
    TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE_2, TAG_CODE_2), TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2);
    tagEntityList.add(tagEntity1);
    tagEntityList.add(tagEntity2);
    List<Integer> tagIds = new ArrayList<>();
    tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId()));
    // Create a document on the search index
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, SEARCH_INDEX_UPDATE_TYPE_CREATE);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("DOCUMENT_TYPE");
    when(tagDao.getTagsByIds(tagIds)).thenReturn(tagEntityList);
    when(tagHelper.safeObjectMapperWriteValueAsString(any(TagEntity.class))).thenReturn("");
    doNothing().when(indexFunctionsDao).createIndexDocuments(any(), any(), any());
    // Call the method under test
    tagService.updateSearchIndexDocumentTag(searchIndexUpdateDto);
    // Verify the calls to external methods
    verify(configurationHelper, times(1)).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(tagDao, times(1)).getTagsByIds(tagIds);
    verify(tagHelper, times(2)).safeObjectMapperWriteValueAsString(any(TagEntity.class));
    verify(indexFunctionsDao, times(1)).createIndexDocuments(any(), any(), any());
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) ArrayList(java.util.ArrayList) TagKey(org.finra.herd.model.api.xml.TagKey) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Test(org.junit.Test)

Example 40 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceTest method testCreateTagMissingOptionalParametersPassedAsWhitespace.

@Test
public void testCreateTagMissingOptionalParametersPassedAsWhitespace() {
    // Create and persist a tag type entity.
    tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create a tag with description passed in as whitespace.
    Tag tag = tagService.createTag(new TagCreateRequest(tagKey, TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, BLANK_TEXT, NO_PARENT_TAG_KEY));
    // Get the tag entity.
    TagEntity tagEntity = tagDao.getTagByKey(tagKey);
    assertNotNull(tagEntity);
    // Validate the response object.
    assertEquals(new Tag(tagEntity.getId(), tagKey, TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, BLANK_TEXT, tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), tag);
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) TagKey(org.finra.herd.model.api.xml.TagKey) TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Aggregations

TagKey (org.finra.herd.model.api.xml.TagKey)140 Test (org.junit.Test)133 TagEntity (org.finra.herd.model.jpa.TagEntity)54 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)39 Tag (org.finra.herd.model.api.xml.Tag)38 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)37 ArrayList (java.util.ArrayList)25 BusinessObjectDefinitionSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter)21 BusinessObjectDefinitionSearchKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey)21 TagUpdateRequest (org.finra.herd.model.api.xml.TagUpdateRequest)17 TagCreateRequest (org.finra.herd.model.api.xml.TagCreateRequest)15 HashSet (java.util.HashSet)13 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)13 BusinessObjectDefinitionSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest)13 BusinessObjectDefinitionSearchResponse (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse)12 TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)12 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)11 BusinessObjectDefinitionTag (org.finra.herd.model.api.xml.BusinessObjectDefinitionTag)10 BusinessObjectDefinitionTagCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagCreateRequest)10 BusinessObjectDefinitionTagKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys)10