BusinessObjectDefinitionDescriptionSuggestionDaoHelper { public BusinessObjectDefinitionDescriptionSuggestionEntity getBusinessObjectDefinitionDescriptionSuggestionEntity( final BusinessObjectDefinitionEntity businessObjectDefinitionEntity, final String userId) { BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity = businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionByBusinessObjectDefinitionAndUserId(businessObjectDefinitionEntity, userId); if (businessObjectDefinitionDescriptionSuggestionEntity == null) { throw new ObjectNotFoundException(String.format("Business object definition description suggestion with the parameters " + " {namespace=\"%s\", businessObjectDefinitionName=\"%s\", userId=\"%s\"} does not exist.", businessObjectDefinitionEntity.getNamespace().getCode(), businessObjectDefinitionEntity.getName(), userId)); } return businessObjectDefinitionDescriptionSuggestionEntity; }  BusinessObjectDefinitionDescriptionSuggestionEntity getBusinessObjectDefinitionDescriptionSuggestionEntity(
        final BusinessObjectDefinitionEntity businessObjectDefinitionEntity, final String userId); List<BusinessObjectDefinitionDescriptionSuggestionEntity> getBusinessObjectDefinitionDescriptionSuggestionsByBusinessObjectDefinitionAndStatus(
        final BusinessObjectDefinitionKey businessObjectDefinitionKey, final String status);  }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionEntity() { BusinessObjectDefinitionEntity businessObjectDefinitionEntity = mock(BusinessObjectDefinitionEntity.class); BusinessObjectDefinitionDescriptionSuggestionEntity businessObjectDefinitionDescriptionSuggestionEntity = new BusinessObjectDefinitionDescriptionSuggestionEntity(); businessObjectDefinitionDescriptionSuggestionEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectDefinitionDescriptionSuggestionEntity.setUserId(USER_ID); businessObjectDefinitionDescriptionSuggestionEntity.setDescriptionSuggestion(DESCRIPTION_SUGGESTION); when(businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionByBusinessObjectDefinitionAndUserId(businessObjectDefinitionEntity, USER_ID)) .thenReturn(businessObjectDefinitionDescriptionSuggestionEntity); BusinessObjectDefinitionDescriptionSuggestionEntity result = businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionEntity(businessObjectDefinitionEntity, USER_ID); assertThat("Result does not equal businessObjectDefinitionDescriptionSuggestionEntity.", result, is(equalTo(businessObjectDefinitionDescriptionSuggestionEntity))); verify(businessObjectDefinitionDescriptionSuggestionDao) .getBusinessObjectDefinitionDescriptionSuggestionByBusinessObjectDefinitionAndUserId(businessObjectDefinitionEntity, USER_ID); verifyNoMoreInteractions(businessObjectDefinitionDescriptionSuggestionDao); }
@Test public void testGetBusinessObjectDefinitionDescriptionSuggestionEntityWithException() { NamespaceEntity namespaceEntity = new NamespaceEntity(); namespaceEntity.setCode(NAMESPACE); BusinessObjectDefinitionEntity businessObjectDefinitionEntity = new BusinessObjectDefinitionEntity(); businessObjectDefinitionEntity.setName(BDEF_NAME); businessObjectDefinitionEntity.setNamespace(namespaceEntity); when(businessObjectDefinitionDescriptionSuggestionDao .getBusinessObjectDefinitionDescriptionSuggestionByBusinessObjectDefinitionAndUserId(businessObjectDefinitionEntity, USER_ID)).thenReturn(null); try { businessObjectDefinitionDescriptionSuggestionDaoHelper .getBusinessObjectDefinitionDescriptionSuggestionEntity(businessObjectDefinitionEntity, USER_ID); fail(); } catch (ObjectNotFoundException objectNotFoundException) { assertThat("Exception message is not correct.", objectNotFoundException.getMessage(), is(equalTo(String.format( "Business object definition description suggestion with the parameters " + " {namespace=\"%s\", businessObjectDefinitionName=\"%s\", userId=\"%s\"} does not exist.", businessObjectDefinitionEntity.getNamespace().getCode(), businessObjectDefinitionEntity.getName(), USER_ID)))); } verify(businessObjectDefinitionDescriptionSuggestionDao) .getBusinessObjectDefinitionDescriptionSuggestionByBusinessObjectDefinitionAndUserId(businessObjectDefinitionEntity, USER_ID); verifyNoMoreInteractions(businessObjectDefinitionDescriptionSuggestionDao); }