@Test public void testExecuteFunctionForBusinessObjectDefinitionEntities() { // Create a list of business object definition entities. final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Collections.unmodifiableList(Arrays.asList( businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes()), businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(BDEF_NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()))); businessObjectDefinitionEntities.forEach(entity -> { entity.setDescriptiveBusinessObjectFormat(new BusinessObjectFormatEntity()); entity.getDescriptiveBusinessObjectFormat().setSchemaColumns(new ArrayList<>()); entity.setSubjectMatterExperts(new ArrayList<>()); }); // Mock the external calls. when(jsonHelper.objectToJson(any())).thenReturn(JSON_STRING); // Execute a function for all business object definition entities. businessObjectDefinitionHelper .executeFunctionForBusinessObjectDefinitionEntities(SEARCH_INDEX_NAME, SEARCH_INDEX_DOCUMENT_TYPE, businessObjectDefinitionEntities, (indexName, documentType, id, json) -> { }); // Verify the external calls. verify(jsonHelper, times(businessObjectDefinitionEntities.size())).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); }
@Test public void testGetBusinessObjectFormatExternalInterfaceEntityExternalInterfaceNoExists() { // Create a business object format to external interface mapping key. BusinessObjectFormatExternalInterfaceKey businessObjectFormatExternalInterfaceKey = new BusinessObjectFormatExternalInterfaceKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, EXTERNAL_INTERFACE); // Create a version-less business object format key. BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null); // Create a business object format entity. BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); // Mock the external calls. when(businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(externalInterfaceDao.getExternalInterfaceByName(EXTERNAL_INTERFACE)).thenReturn(null); // Specify the expected exception. expectedException.expect(ObjectNotFoundException.class); expectedException.expectMessage(String.format("Business object format to external interface mapping with \"%s\" namespace, " + "\"%s\" business object definition name, \"%s\" business object format usage, \"%s\" business object format file type, and " + "\"%s\" external interface name doesn't exist.", NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, EXTERNAL_INTERFACE)); // Call the method under test. businessObjectFormatExternalInterfaceDaoHelper.getBusinessObjectFormatExternalInterfaceEntity(businessObjectFormatExternalInterfaceKey); // Verify the external calls. verify(businessObjectFormatDao).getBusinessObjectFormatByAltKey(businessObjectFormatKey); verify(externalInterfaceDao).getExternalInterfaceByName(EXTERNAL_INTERFACE); verifyNoMoreInteractionsHelper(); }
@Test public void testExecuteFunctionForBusinessObjectDefinitionEntitiesJsonParseException() { // Create a list of business object definition entities. final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Collections.unmodifiableList(Arrays.asList( businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes()), businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(BDEF_NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()))); businessObjectDefinitionEntities.forEach(entity -> { entity.setDescriptiveBusinessObjectFormat(new BusinessObjectFormatEntity()); entity.getDescriptiveBusinessObjectFormat().setSchemaColumns(new ArrayList<>()); entity.setSubjectMatterExperts(new ArrayList<>()); }); // Mock the external calls. when(jsonHelper.objectToJson(any())) .thenThrow(new IllegalStateException(new JsonParseException("Failed to Parse", new JsonLocation("SRC", 100L, 1, 2)))); // Execute a function for all business object definition entities. businessObjectDefinitionHelper .executeFunctionForBusinessObjectDefinitionEntities(SEARCH_INDEX_NAME, SEARCH_INDEX_DOCUMENT_TYPE, businessObjectDefinitionEntities, (indexName, documentType, id, json) -> { }); // Verify the external calls. verify(jsonHelper, times(businessObjectDefinitionEntities.size())).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); }
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION); businessObjectFormatEntity.setLatestVersion(false); BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = new BusinessObjectFormatEntity(); latestVersionBusinessObjectFormatEntity.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION); latestVersionBusinessObjectFormatEntity.setLatestVersion(true);
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setLatestVersion(true); businessObjectFormatEntity.setRetentionType(retentionTypeEntity);
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setRetentionType(retentionTypeEntity);
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
List<BusinessObjectFormatEntity> businessObjectFormatEntityParents) BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectFormatEntity.setUsage(request.getBusinessObjectFormatUsage());
List<BusinessObjectFormatEntity> businessObjectFormatEntityParents) BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectFormatEntity.setUsage(request.getBusinessObjectFormatUsage());
/** * Creates and persists a new business object format entity. * * @return the newly created business object format entity. */ public BusinessObjectFormatEntity createBusinessObjectFormatEntity(boolean includeAttributeDefinition) { BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinition()); businessObjectFormatEntity.setDescription("test"); businessObjectFormatEntity.setFileType(fileTypeDaoTestHelper.createFileTypeEntity()); businessObjectFormatEntity.setBusinessObjectFormatVersion(0); businessObjectFormatEntity.setLatestVersion(true); businessObjectFormatEntity.setUsage("PRC"); businessObjectFormatEntity.setPartitionKey("testPartitionKey"); if (includeAttributeDefinition) { List<BusinessObjectDataAttributeDefinitionEntity> attributeDefinitionEntities = new ArrayList<>(); businessObjectFormatEntity.setAttributeDefinitions(attributeDefinitionEntities); BusinessObjectDataAttributeDefinitionEntity attributeDefinitionEntity = new BusinessObjectDataAttributeDefinitionEntity(); attributeDefinitionEntities.add(attributeDefinitionEntity); attributeDefinitionEntity.setBusinessObjectFormat(businessObjectFormatEntity); attributeDefinitionEntity.setName(AbstractDaoTest.ATTRIBUTE_NAME_1_MIXED_CASE); } return businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity); }
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectFormatEntity.setUsage(FORMAT_USAGE_CODE);
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); businessObjectFormatEntity.setUsage(FORMAT_USAGE_CODE);