BusinessObjectDefinitionDescriptionSuggestionDaoHelper { public List<BusinessObjectDefinitionDescriptionSuggestionEntity> getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus( final BusinessObjectDefinitionKey businessObjectDefinitionKey, final String status) { BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); if (businessObjectDefinitionEntity == null) { return Lists.newArrayList(); } BusinessObjectDefinitionDescriptionSuggestionStatusEntity businessObjectDefinitionDescriptionSuggestionStatusEntity = null; if (StringUtils.isNotBlank(status)) { businessObjectDefinitionDescriptionSuggestionStatusEntity = businessObjectDefinitionDescriptionSuggestionStatusDao.getBusinessObjectDefinitionDescriptionSuggestionStatusByCode(status); if (businessObjectDefinitionDescriptionSuggestionStatusEntity == null) { return Lists.newArrayList(); } } List<BusinessObjectDefinitionDescriptionSuggestionEntity> businessObjectDefinitionDescriptionSuggestionEntities = businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, businessObjectDefinitionDescriptionSuggestionStatusEntity); if (businessObjectDefinitionDescriptionSuggestionEntities == null) { return Lists.newArrayList(); } return businessObjectDefinitionDescriptionSuggestionEntities; }  BusinessObjectDefinitionDescriptionSuggestionEntity getBusinessObjectDefinitionDescriptionSuggestionEntity(
        final BusinessObjectDefinitionEntity businessObjectDefinitionEntity, final String userId); List<BusinessObjectDefinitionDescriptionSuggestionEntity> getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(
        final BusinessObjectDefinitionKey businessObjectDefinitionKey, final String status);  }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus() { NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE); BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(namespaceEntity.getCode(), BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION); BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME); BusinessObjectDefinitionDescriptionSuggestionStatusEntity businessObjectDefinitionDescriptionSuggestionStatusEntity = businessObjectDefinitionDescriptionSuggestionStatusDaoTestHelper .createBusinessObjectDefinitionDescriptionSuggestionStatusEntity(BDEF_DESCRIPTION_SUGGESTION_STATUS); BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity = new BusinessObjectDefinitionDescriptionSuggestionEntity(); businessObjectDefinitionDescriptionSuggestionEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectDefinitionDescriptionSuggestionEntity.setDescriptionSuggestion(DESCRIPTION_SUGGESTION); businessObjectDefinitionDescriptionSuggestionEntity.setUserId(USER_ID); businessObjectDefinitionDescriptionSuggestionEntity.setStatus(businessObjectDefinitionDescriptionSuggestionStatusEntity); BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity2 = new BusinessObjectDefinitionDescriptionSuggestionEntity(); businessObjectDefinitionDescriptionSuggestionEntity2.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectDefinitionDescriptionSuggestionEntity2.setDescriptionSuggestion(DESCRIPTION_SUGGESTION_2); businessObjectDefinitionDescriptionSuggestionEntity2.setUserId(USER_ID_2); businessObjectDefinitionDescriptionSuggestionEntity2.setStatus(businessObjectDefinitionDescriptionSuggestionStatusEntity); List<BusinessObjectDefinitionDescriptionSuggestionEntity> businessObjectDefinitionDescriptionSuggestionEntities = Lists.newArrayList(businessObjectDefinitionDescriptionSuggestionEntity, businessObjectDefinitionDescriptionSuggestionEntity2); when(businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey)).thenReturn(businessObjectDefinitionEntity); when(businessObjectDefinitionDescriptionSuggestionStatusDao .getBusinessObjectDefinitionDescriptionSuggestionStatusByCode(BDEF_DESCRIPTION_SUGGESTION_STATUS)) .thenReturn(businessObjectDefinitionDescriptionSuggestionStatusEntity); when(businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, businessObjectDefinitionDescriptionSuggestionStatusEntity)).thenReturn(businessObjectDefinitionDescriptionSuggestionEntities); List<BusinessObjectDefinitionDescriptionSuggestionEntity> result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionKey, BDEF_DESCRIPTION_SUGGESTION_STATUS); assertThat("Result size does not equal businessObjectDefinitionDescriptionSuggestionEntities.", result.size(), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.size()))); for (int i = 0; i < result.size(); i++) { assertThat("Result is not equal businessObjectDefinitionDescriptionSuggestionEntity.", result.get(i), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.get(i)))); } verify(businessObjectDefinitionDao).getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); verify(businessObjectDefinitionDescriptionSuggestionStatusDao) .getBusinessObjectDefinitionDescriptionSuggestionStatusByCode(BDEF_DESCRIPTION_SUGGESTION_STATUS); verify(businessObjectDefinitionDescriptionSuggestionDao) .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, businessObjectDefinitionDescriptionSuggestionStatusEntity); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionDescriptionSuggestionDao, businessObjectDefinitionDescriptionSuggestionStatusDao); }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatusWithEmptyStatus() { NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE); BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(namespaceEntity.getCode(), BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION); BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME); BusinessObjectDefinitionDescriptionSuggestionStatusEntity businessObjectDefinitionDescriptionSuggestionStatusEntity = businessObjectDefinitionDescriptionSuggestionStatusDaoTestHelper .createBusinessObjectDefinitionDescriptionSuggestionStatusEntity(BDEF_DESCRIPTION_SUGGESTION_STATUS); BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity = new BusinessObjectDefinitionDescriptionSuggestionEntity(); businessObjectDefinitionDescriptionSuggestionEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectDefinitionDescriptionSuggestionEntity.setDescriptionSuggestion(DESCRIPTION_SUGGESTION); businessObjectDefinitionDescriptionSuggestionEntity.setUserId(USER_ID); businessObjectDefinitionDescriptionSuggestionEntity.setStatus(businessObjectDefinitionDescriptionSuggestionStatusEntity); BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity2 = new BusinessObjectDefinitionDescriptionSuggestionEntity(); businessObjectDefinitionDescriptionSuggestionEntity2.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectDefinitionDescriptionSuggestionEntity2.setDescriptionSuggestion(DESCRIPTION_SUGGESTION_2); businessObjectDefinitionDescriptionSuggestionEntity2.setUserId(USER_ID_2); businessObjectDefinitionDescriptionSuggestionEntity2.setStatus(businessObjectDefinitionDescriptionSuggestionStatusEntity); List<BusinessObjectDefinitionDescriptionSuggestionEntity> businessObjectDefinitionDescriptionSuggestionEntities = Lists.newArrayList(businessObjectDefinitionDescriptionSuggestionEntity, businessObjectDefinitionDescriptionSuggestionEntity2); when(businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey)).thenReturn(businessObjectDefinitionEntity); when(businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, null)) .thenReturn(businessObjectDefinitionDescriptionSuggestionEntities); List<BusinessObjectDefinitionDescriptionSuggestionEntity> result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionKey, ""); assertThat("Result size does not equal businessObjectDefinitionDescriptionSuggestionEntities.", result.size(), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.size()))); for (int i = 0; i < result.size(); i++) { assertThat("Result is not equal businessObjectDefinitionDescriptionSuggestionEntity.", result.get(i), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.get(i)))); } verify(businessObjectDefinitionDao).getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); verify(businessObjectDefinitionDescriptionSuggestionDao) .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, null); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionDescriptionSuggestionDao, businessObjectDefinitionDescriptionSuggestionStatusDao); reset(businessObjectDefinitionDao); reset(businessObjectDefinitionDescriptionSuggestionDao); when(businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey)).thenReturn(businessObjectDefinitionEntity); when(businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, null)) .thenReturn(businessObjectDefinitionDescriptionSuggestionEntities); result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionKey, " "); assertThat("Result size does not equal businessObjectDefinitionDescriptionSuggestionEntities.", result.size(), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.size()))); for (int i = 0; i < result.size(); i++) { assertThat("Result is not equal businessObjectDefinitionDescriptionSuggestionEntity.", result.get(i), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.get(i)))); } verify(businessObjectDefinitionDao).getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); verify(businessObjectDefinitionDescriptionSuggestionDao) .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, null); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionDescriptionSuggestionDao, businessObjectDefinitionDescriptionSuggestionStatusDao); }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatusWithNullStatus() { NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE); BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(namespaceEntity.getCode(), BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION); BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME); BusinessObjectDefinitionDescriptionSuggestionStatusEntity businessObjectDefinitionDescriptionSuggestionStatusEntity = businessObjectDefinitionDescriptionSuggestionStatusDaoTestHelper .createBusinessObjectDefinitionDescriptionSuggestionStatusEntity(BDEF_DESCRIPTION_SUGGESTION_STATUS); BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity = new BusinessObjectDefinitionDescriptionSuggestionEntity(); businessObjectDefinitionDescriptionSuggestionEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectDefinitionDescriptionSuggestionEntity.setDescriptionSuggestion(DESCRIPTION_SUGGESTION); businessObjectDefinitionDescriptionSuggestionEntity.setUserId(USER_ID); businessObjectDefinitionDescriptionSuggestionEntity.setStatus(businessObjectDefinitionDescriptionSuggestionStatusEntity); BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity2 = new BusinessObjectDefinitionDescriptionSuggestionEntity(); businessObjectDefinitionDescriptionSuggestionEntity2.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectDefinitionDescriptionSuggestionEntity2.setDescriptionSuggestion(DESCRIPTION_SUGGESTION_2); businessObjectDefinitionDescriptionSuggestionEntity2.setUserId(USER_ID_2); businessObjectDefinitionDescriptionSuggestionEntity2.setStatus(businessObjectDefinitionDescriptionSuggestionStatusEntity); List<BusinessObjectDefinitionDescriptionSuggestionEntity> businessObjectDefinitionDescriptionSuggestionEntities = Lists.newArrayList(businessObjectDefinitionDescriptionSuggestionEntity, businessObjectDefinitionDescriptionSuggestionEntity2); when(businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey)).thenReturn(businessObjectDefinitionEntity); when(businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, null)) .thenReturn(businessObjectDefinitionDescriptionSuggestionEntities); List<BusinessObjectDefinitionDescriptionSuggestionEntity> result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionKey, null); assertThat("Result size does not equal businessObjectDefinitionDescriptionSuggestionEntities.", result.size(), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.size()))); for (int i = 0; i < result.size(); i++) { assertThat("Result is not equal businessObjectDefinitionDescriptionSuggestionEntity.", result.get(i), is(equalTo(businessObjectDefinitionDescriptionSuggestionEntities.get(i)))); } verify(businessObjectDefinitionDao).getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); verify(businessObjectDefinitionDescriptionSuggestionDao) .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, null); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionDescriptionSuggestionDao, businessObjectDefinitionDescriptionSuggestionStatusDao); }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatusWithEmptyResultList() { NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE); BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(namespaceEntity.getCode(), BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION); BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME); BusinessObjectDefinitionDescriptionSuggestionStatusEntity businessObjectDefinitionDescriptionSuggestionStatusEntity = businessObjectDefinitionDescriptionSuggestionStatusDaoTestHelper .createBusinessObjectDefinitionDescriptionSuggestionStatusEntity(BDEF_DESCRIPTION_SUGGESTION_STATUS); when(businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey)).thenReturn(businessObjectDefinitionEntity); when(businessObjectDefinitionDescriptionSuggestionStatusDao .getBusinessObjectDefinitionDescriptionSuggestionStatusByCode(BDEF_DESCRIPTION_SUGGESTION_STATUS)) .thenReturn(businessObjectDefinitionDescriptionSuggestionStatusEntity); when(businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, businessObjectDefinitionDescriptionSuggestionStatusEntity)).thenReturn(null); List<BusinessObjectDefinitionDescriptionSuggestionEntity> result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionKey, BDEF_DESCRIPTION_SUGGESTION_STATUS); assertThat("Result size does not equal zero.", result.size(), is(equalTo(0))); verify(businessObjectDefinitionDao).getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); verify(businessObjectDefinitionDescriptionSuggestionStatusDao) .getBusinessObjectDefinitionDescriptionSuggestionStatusByCode(BDEF_DESCRIPTION_SUGGESTION_STATUS); verify(businessObjectDefinitionDescriptionSuggestionDao) .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionEntity, businessObjectDefinitionDescriptionSuggestionStatusEntity); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionDescriptionSuggestionDao, businessObjectDefinitionDescriptionSuggestionStatusDao); }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatusWithNullBusinessObjectDefinition() { BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME); when(businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey)).thenReturn(null); List<BusinessObjectDefinitionDescriptionSuggestionEntity> result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionKey, BDEF_DESCRIPTION_SUGGESTION_STATUS); assertThat("Result size does not equal zero.", result.size(), is(equalTo(0))); verify(businessObjectDefinitionDao).getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionDescriptionSuggestionDao, businessObjectDefinitionDescriptionSuggestionStatusDao); }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatusWithNoStatusEntityFound() { NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE); BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(namespaceEntity.getCode(), BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION); BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME); when(businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey)).thenReturn(businessObjectDefinitionEntity); when(businessObjectDefinitionDescriptionSuggestionStatusDao .getBusinessObjectDefinitionDescriptionSuggestionStatusByCode(BDEF_DESCRIPTION_SUGGESTION_STATUS)).thenReturn(null); List<BusinessObjectDefinitionDescriptionSuggestionEntity> result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(businessObjectDefinitionKey, BDEF_DESCRIPTION_SUGGESTION_STATUS); assertThat("Result size does not equal zero.", result.size(), is(equalTo(0))); verify(businessObjectDefinitionDao).getBusinessObjectDefinitionByKey(businessObjectDefinitionKey); verify(businessObjectDefinitionDescriptionSuggestionStatusDao) .getBusinessObjectDefinitionDescriptionSuggestionStatusByCode(BDEF_DESCRIPTION_SUGGESTION_STATUS); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionDescriptionSuggestionDao, businessObjectDefinitionDescriptionSuggestionStatusDao); }