BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatEntity.getLatestVersion() ? businessObjectFormatEntity : businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey);
BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatEntity.getLatestVersion() ? businessObjectFormatEntity : businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey);
@Test public void testGetBusinessObjectFormatByAltKeyAllParamsLowerCase() { // Create relative database entities. businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), DATA_PROVIDER_NAME.toUpperCase(), BDEF_DESCRIPTION); fileTypeDaoTestHelper.createFileTypeEntity(FORMAT_FILE_TYPE_CODE.toUpperCase(), "Description of " + FORMAT_FILE_TYPE_CODE); businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), INITIAL_FORMAT_VERSION, "Test format 0", "Document Schema 0", Boolean.TRUE, PARTITION_KEY); // Retrieve business object format entity by specifying values for all text alternate key fields in lower case. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey( new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), INITIAL_FORMAT_VERSION)); // Validate the results. assertNotNull(businessObjectFormatEntity); assertTrue(businessObjectFormatEntity.getBusinessObjectDefinition().getName().equals(BDEF_NAME.toUpperCase())); assertTrue(businessObjectFormatEntity.getUsage().equals(FORMAT_USAGE_CODE.toUpperCase())); assertTrue(businessObjectFormatEntity.getFileType().getCode().equals(FORMAT_FILE_TYPE_CODE.toUpperCase())); assertTrue(businessObjectFormatEntity.getBusinessObjectFormatVersion().equals(INITIAL_FORMAT_VERSION)); assertTrue(businessObjectFormatEntity.getLatestVersion()); assertTrue(businessObjectFormatEntity.getPartitionKey().equals(PARTITION_KEY)); assertTrue(businessObjectFormatEntity.getDescription().equals("Test format 0")); assertTrue(businessObjectFormatEntity.getDocumentSchema().equals("Document Schema 0")); }
@Test public void testGetBusinessObjectFormatByAltKeyAllParamsUpperCase() { // Create relative database entities. businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), DATA_PROVIDER_NAME.toLowerCase(), BDEF_DESCRIPTION); fileTypeDaoTestHelper.createFileTypeEntity(FORMAT_FILE_TYPE_CODE.toLowerCase(), "Description of " + FORMAT_FILE_TYPE_CODE); businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), INITIAL_FORMAT_VERSION, "Test format 0", "Document Schema 0", Boolean.TRUE, PARTITION_KEY); // Retrieve business object format entity by specifying values for all text alternate key fields in upper case. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey( new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), INITIAL_FORMAT_VERSION)); // Validate the results. assertNotNull(businessObjectFormatEntity); assertTrue(businessObjectFormatEntity.getBusinessObjectDefinition().getName().equals(BDEF_NAME.toLowerCase())); assertTrue(businessObjectFormatEntity.getUsage().equals(FORMAT_USAGE_CODE.toLowerCase())); assertTrue(businessObjectFormatEntity.getFileType().getCode().equals(FORMAT_FILE_TYPE_CODE.toLowerCase())); assertTrue(businessObjectFormatEntity.getBusinessObjectFormatVersion().equals(INITIAL_FORMAT_VERSION)); assertTrue(businessObjectFormatEntity.getLatestVersion()); assertTrue(businessObjectFormatEntity.getPartitionKey().equals(PARTITION_KEY)); assertTrue(businessObjectFormatEntity.getDescription().equals("Test format 0")); assertTrue(businessObjectFormatEntity.getDocumentSchema().equals("Document Schema 0")); }
if (businessObjectFormatEntity.getLatestVersion())
if (businessObjectFormatEntity.getLatestVersion())
assertFalse(initialVersionBusinessObjectFormatEntity.getLatestVersion()); assertTrue(latestVersionBusinessObjectFormatEntity.getLatestVersion()); new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION)); assertNotNull(initialVersionBusinessObjectFormatEntity); assertTrue(initialVersionBusinessObjectFormatEntity.getLatestVersion());
businessObjectFormat.setBusinessObjectFormatFileType(businessObjectFormatEntity.getFileType().getCode()); businessObjectFormat.setBusinessObjectFormatVersion(businessObjectFormatEntity.getBusinessObjectFormatVersion()); businessObjectFormat.setLatestVersion(businessObjectFormatEntity.getLatestVersion()); businessObjectFormat.setPartitionKey(businessObjectFormatEntity.getPartitionKey()); businessObjectFormat.setDescription(businessObjectFormatEntity.getDescription());
businessObjectFormat.setBusinessObjectFormatFileType(businessObjectFormatEntity.getFileType().getCode()); businessObjectFormat.setBusinessObjectFormatVersion(businessObjectFormatEntity.getBusinessObjectFormatVersion()); businessObjectFormat.setLatestVersion(businessObjectFormatEntity.getLatestVersion()); businessObjectFormat.setPartitionKey(businessObjectFormatEntity.getPartitionKey()); businessObjectFormat.setDescription(businessObjectFormatEntity.getDescription());
assertTrue(businessObjectFormatEntity.getFileType().getCode().equals(FORMAT_FILE_TYPE_CODE)); assertTrue(businessObjectFormatEntity.getBusinessObjectFormatVersion() == 1); assertTrue(businessObjectFormatEntity.getLatestVersion()); assertTrue(businessObjectFormatEntity.getPartitionKey().equals(PARTITION_KEY)); assertTrue(businessObjectFormatEntity.getDescription().equals("Test format 1"));
assertTrue(businessObjectFormatEntity.getFileType().getCode().equals(FORMAT_FILE_TYPE_CODE)); assertTrue(businessObjectFormatEntity.getBusinessObjectFormatVersion() == businessObjectFormatVersion); assertTrue(businessObjectFormatEntity.getLatestVersion() == (businessObjectFormatVersion == 1)); assertTrue(businessObjectFormatEntity.getPartitionKey().equals(PARTITION_KEY)); assertTrue(businessObjectFormatEntity.getDescription().equals(String.format("Test format %d", businessObjectFormatVersion)));
@Test public void testCreateBusinessObjectFormatCreateSecondVersion() { // Create an initial version of a business object format. businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(); // Create a second version of the business object format. BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema()); BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), resultBusinessObjectFormat); // Check if we now have only one latest format version - our first version is not marked as latest anymore. // Please note that we do not have to validate if the first format version is not marked as "latest" now, since having more that one // format versions with the latestVersion flag set to Yes produces exception in herdDao.getBusinessObjectFormatByAltKey() method. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao .getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null)); assertEquals(SECOND_FORMAT_VERSION, businessObjectFormatEntity.getBusinessObjectFormatVersion()); assertEquals(true, businessObjectFormatEntity.getLatestVersion()); }
.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null)); assertEquals(SECOND_FORMAT_VERSION, businessObjectFormatEntity.getBusinessObjectFormatVersion()); assertEquals(true, businessObjectFormatEntity.getLatestVersion());