@@ -4661,26 +4661,27 @@ public void testCreateBusinessObjectFormatWithAllowNonBackwardsCompatibleChanges
4661
4661
businessObjectFormatServiceTestHelper .createTestDatabaseEntitiesForBusinessObjectFormatTesting ();
4662
4662
4663
4663
// Create an initial version of a business object format with a schema.
4664
- BusinessObjectFormat businessObjectFormat = businessObjectFormatService .createBusinessObjectFormat (businessObjectFormatServiceTestHelper
4664
+ BusinessObjectFormat businessObjectFormatV0 = businessObjectFormatService .createBusinessObjectFormat (businessObjectFormatServiceTestHelper
4665
4665
.createBusinessObjectFormatCreateRequest (NAMESPACE , BDEF_NAME , FORMAT_USAGE_CODE , FORMAT_FILE_TYPE_CODE , PARTITION_KEY , FORMAT_DESCRIPTION ,
4666
4666
businessObjectDefinitionServiceTestHelper .getNewAttributes (), businessObjectFormatServiceTestHelper .getTestAttributeDefinitions (),
4667
4667
businessObjectFormatServiceTestHelper .getTestSchema ()));
4668
4668
4669
- // Validate allowNonBackwardsCompatibleChanges is not set.
4670
- assertNull (businessObjectFormat .isAllowNonBackwardsCompatibleChanges ());
4669
+ // Validate allowNonBackwardsCompatibleChanges is not set on businessObjectFormatV0
4670
+ assertNull (businessObjectFormatV0 .isAllowNonBackwardsCompatibleChanges ());
4671
4671
4672
- // Create business object format key for the initial version of the format.
4673
- BusinessObjectFormatKey businessObjectFormatKey =
4672
+ // Create business object format key for format V0 .
4673
+ BusinessObjectFormatKey businessObjectFormatKeyV0 =
4674
4674
new BusinessObjectFormatKey (NAMESPACE , BDEF_NAME , FORMAT_USAGE_CODE , FORMAT_FILE_TYPE_CODE , INITIAL_FORMAT_VERSION );
4675
4675
4676
- // Create a business object format create request with non-backwards compatible schema changes.
4677
- // Try to create a second version of the business object format with a schema that has a different null value.
4678
- Schema newSchema = businessObjectFormatServiceTestHelper .getTestSchema ();
4679
- newSchema .setNullValue (SCHEMA_NULL_VALUE_NULL_WORD );
4676
+ // Create a business object format create request with non-backwards compatible schema changes, schema that has a different null value.
4677
+ Schema nonBackwardsCompatibleSchema = businessObjectFormatServiceTestHelper .getTestSchema ();
4678
+ nonBackwardsCompatibleSchema .setNullValue (SCHEMA_NULL_VALUE_NULL_WORD );
4680
4679
BusinessObjectFormatCreateRequest businessObjectFormatCreateRequest = businessObjectFormatServiceTestHelper
4681
4680
.createBusinessObjectFormatCreateRequest (NAMESPACE , BDEF_NAME , FORMAT_USAGE_CODE , FORMAT_FILE_TYPE_CODE , PARTITION_KEY , FORMAT_DESCRIPTION ,
4682
- businessObjectDefinitionServiceTestHelper .getNewAttributes (), businessObjectFormatServiceTestHelper .getTestAttributeDefinitions (), newSchema );
4681
+ businessObjectDefinitionServiceTestHelper .getNewAttributes (), businessObjectFormatServiceTestHelper .getTestAttributeDefinitions (),
4682
+ nonBackwardsCompatibleSchema );
4683
4683
4684
+ // Try to create a second version of the business object format with non-backwards compatible schema changes.
4684
4685
// We expected to fail as allowNonBackwardsCompatibleChanges is not set.
4685
4686
try
4686
4687
{
@@ -4693,14 +4694,15 @@ public void testCreateBusinessObjectFormatWithAllowNonBackwardsCompatibleChanges
4693
4694
"New format version null value does not match to the previous format version null value." , e .getMessage ());
4694
4695
}
4695
4696
4696
- // Get the business object format entity by alternate key .
4697
- BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao .getBusinessObjectFormatByAltKey (businessObjectFormatKey );
4698
- assertNotNull (businessObjectFormatEntity );
4697
+ // Get the initial format version of the business object format entity.
4698
+ BusinessObjectFormatEntity businessObjectFormatEntityV0 = businessObjectFormatDao .getBusinessObjectFormatByAltKey (businessObjectFormatKeyV0 );
4699
+ assertNotNull (businessObjectFormatEntityV0 );
4699
4700
4700
- // Update allowNonBackwardsCompatibleChanges to false.
4701
- businessObjectFormatEntity .setAllowNonBackwardsCompatibleChanges (false );
4702
- assertFalse (businessObjectFormatEntity .isAllowNonBackwardsCompatibleChanges ());
4701
+ // Update businessObjectFormatEntityV0 to allowNonBackwardsCompatibleChanges to false.
4702
+ businessObjectFormatEntityV0 .setAllowNonBackwardsCompatibleChanges (false );
4703
+ assertFalse (businessObjectFormatEntityV0 .isAllowNonBackwardsCompatibleChanges ());
4703
4704
4705
+ // Try to create a second version of the business object format with non-backwards compatible schema changes..
4704
4706
// We expected to fail as allowNonBackwardsCompatibleChanges is set to false.
4705
4707
try
4706
4708
{
@@ -4713,21 +4715,43 @@ public void testCreateBusinessObjectFormatWithAllowNonBackwardsCompatibleChanges
4713
4715
"New format version null value does not match to the previous format version null value." , e .getMessage ());
4714
4716
}
4715
4717
4716
- // Get the business object format entity by alternate key .
4717
- businessObjectFormatEntity = businessObjectFormatDao . getBusinessObjectFormatByAltKey ( businessObjectFormatKey );
4718
- assertNotNull ( businessObjectFormatEntity );
4718
+ // Get the initial format version and validate that the allowNonBackwardsCompatibleChanges is set to false .
4719
+ businessObjectFormatV0 = businessObjectFormatService . getBusinessObjectFormat ( businessObjectFormatKeyV0 );
4720
+ assertFalse ( businessObjectFormatV0 . isAllowNonBackwardsCompatibleChanges () );
4719
4721
4720
- // Update allowNonBackwardsCompatibleChanges to true.
4721
- businessObjectFormatEntity .setAllowNonBackwardsCompatibleChanges (true );
4722
- assertTrue (businessObjectFormatEntity .isAllowNonBackwardsCompatibleChanges ());
4722
+ // Update businessObjectFormatEntityV0 to allowNonBackwardsCompatibleChanges to true.
4723
+ businessObjectFormatEntityV0 .setAllowNonBackwardsCompatibleChanges (true );
4724
+ assertTrue (businessObjectFormatEntityV0 .isAllowNonBackwardsCompatibleChanges ());
4723
4725
4724
4726
// Call create business object format when allowNonBackwardsCompatibleChanges is set to true.
4725
- businessObjectFormat = businessObjectFormatService .createBusinessObjectFormat (businessObjectFormatCreateRequest );
4727
+ BusinessObjectFormat businessObjectFormatV1 = businessObjectFormatService .createBusinessObjectFormat (businessObjectFormatCreateRequest );
4728
+
4729
+ // Validate businessObjectFormatV1 and businessObjectFormatEntityV0.
4730
+ assertNotNull (businessObjectFormatV1 );
4731
+ assertEquals (true , businessObjectFormatV1 .isAllowNonBackwardsCompatibleChanges ());
4732
+ assertEquals (SECOND_FORMAT_VERSION , Integer .valueOf (businessObjectFormatV1 .getBusinessObjectFormatVersion ()));
4733
+ assertNull (businessObjectFormatEntityV0 .isAllowNonBackwardsCompatibleChanges ());
4734
+
4735
+ // Get the initial format version and validate that the allowNonBackwardsCompatibleChanges is set to true.
4736
+ businessObjectFormatV0 = businessObjectFormatService .getBusinessObjectFormat (businessObjectFormatKeyV0 );
4737
+ assertTrue (businessObjectFormatV0 .isAllowNonBackwardsCompatibleChanges ());
4738
+
4739
+ // Delete the second version of business object format.
4740
+ BusinessObjectFormat deletedBusinessObjectFormat = businessObjectFormatService
4741
+ .deleteBusinessObjectFormat (new BusinessObjectFormatKey (NAMESPACE , BDEF_NAME , FORMAT_USAGE_CODE , FORMAT_FILE_TYPE_CODE , SECOND_FORMAT_VERSION ));
4742
+ assertNotNull (deletedBusinessObjectFormat );
4743
+ assertTrue (deletedBusinessObjectFormat .isAllowNonBackwardsCompatibleChanges ());
4744
+
4745
+ // Get the initial format version of the business object format entity.
4746
+ businessObjectFormatEntityV0 = businessObjectFormatDao .getBusinessObjectFormatByAltKey (businessObjectFormatKeyV0 );
4747
+
4748
+ // Validate the schema compatibility changes got propagated to the latest format version.
4749
+ assertNotNull (businessObjectFormatEntityV0 );
4750
+ assertEquals (true , businessObjectFormatEntityV0 .isAllowNonBackwardsCompatibleChanges ());
4751
+ assertEquals (INITIAL_FORMAT_VERSION , Integer .valueOf (businessObjectFormatEntityV0 .getBusinessObjectFormatVersion ()));
4726
4752
4727
- // Validate results.
4728
- assertNotNull (businessObjectFormat );
4729
- assertEquals (true , businessObjectFormat .isAllowNonBackwardsCompatibleChanges ());
4730
- assertEquals (SECOND_FORMAT_VERSION , Integer .valueOf (businessObjectFormat .getBusinessObjectFormatVersion ()));
4753
+ // Validate initial version business object format entity.
4754
+ assertTrue (businessObjectFormatEntityV0 .isAllowNonBackwardsCompatibleChanges ());
4731
4755
}
4732
4756
4733
4757
private GlobalAttributeDefinitionEntity createGlobalAttributeDefinitionEntityWithAllowedAttributeValues ()
0 commit comments