meta data for this page
  •  

This is an old revision of the document!


SystemSetup Annotation: When are the methods run?

The SystemSetup annotation is used to run import data, synchronize catalogues, migrate CMS components and execute Java code during every project or essential data creation step.

In all hybris version up to 1905 the essential and project data steps aren't run during the initialization of the junit tenant. This prevented the import of common test data for complex integration tests if you weren't using the Areco deployment script manager as patch system. To get an updated picture of the current situation, I ran a test on the latest SAP hybris version 1905 and here are the results are the same as with old versions:

SystemSetup.ProcessINITUPDATEALL.
SystemSetup.TypeESSENTIALPROJECTALLESSENTIALPROJECTALLESSENTIALPROJECTALLWhat Hybris impexes are imported?
ant initialize -Dtenant=masterCalled once with process INIT and type ESSENTIALCalled once with process INIT and type PROJECTCalled twice with process INIT and type ESSENTIAL
and with process INIT and type PROJECT
No callCalled once with process INIT and type ESSENTIALCalled once with process INIT and type PROJECTCalled twice with process INIT and type ESSENTIAL
and with process INIT and type PROJECT
Project and essential scripts
ant initialize -Dtenant=junit:!: No call:!: None
ant yunitinit:!: No call:!: None
ant updatesystem -Dtenant=master1)No callCalled once with process UPDATE and type ESSENTIALCalled once with process UPDATE and type PROJECTCalled twice with process UPDATE and type ESSENTIAL and with process UPDATE and type PROJECTCalled once with process UPDATE and type ESSENTIALCalled once with process UPDATE and type PROJECTCalled twice with process INIT and type ESSENTIAL and with process INIT and type PROJECTProject and essential scripts
ant updatesystem -Dtenant=junit2):!: No call:!: None
ant yunitupdate:!: No call:!: None

When @SystemSetup(extension = ArecosystemsetuptestConstants.EXTENSIONNAME), the field hybrisContext.getExtensionName() always contains the name of the current extension.
When @SystemSetup(extension = “ALL_EXTENSIONS”) is used, the methods annotated with @SystemSetup are called as above once or twice per each hybris and custom extension. Each time the field hybrisContext.getExtensionName() contains the name of a different extension.

Because the mayority of the SAP hybris projects use Jenkins and ant targets to deploy, update system and initialization using HAC wasn't tested.

Test description

I created a new extension based on the templa yempty and added the property initialpassword.admin=nimda to the local.properies. Then I created a class for the test and annotated at class level with:

@SystemSetup(extension = ArecosystemsetuptestConstants.EXTENSIONNAME)
public class SystemSetupAnnotationCallsTest {

Each method contains the following code for all possible combinations of process and type:

@SystemSetup(process = SystemSetup.Process.UPDATE, type = SystemSetup.Type.ESSENTIAL)
public void logUpdateEssential(final SystemSetupContext hybrisContext) {
  LOG.error(String.format("Called Update Essential with extension %s, process %s and type %s", hybrisContext.getExtensionName(), hybrisContext.getProcess(), hybrisContext.getType()));
}

To make hybris call the methods, I had to create a bean definition in the spring application context. Autowiring without the XML bean definition wasn't working.

    <bean id="systemSetupAnnotationCallsTest" class="org.areco.ecommerce.tests.systemsetup.setup.SystemSetupAnnotationCallsTest" />

I ran the following commands and I analysed the log afterwards:

rm -rf hybris/data/
ant clean all
ant initialize -Dtenant=master | tee initializeMaster.log | grep SystemSetupAnnotationCallsTest
ant initialize -Dtenant=junit | tee initializeJunit.log | grep SystemSetupAnnotationCallsTest
ant yunitinit | tee yunitinit.log | grep SystemSetupAnnotationCallsTest
ant updatesystem -Dtenant=master -DconfigFile=/home/arobirosa/no_backup/areco/arecodeploymentscriptsmanager-1905/hybris/bin/custom/arecosystemsetuptest/resources/updateSystemConfigFile.json | tee updateMaster.log | grep SystemSetupAnnotationCallsTest
ant updatesystem -Dtenant=yunit -DconfigFile=/home/arobirosa/no_backup/areco/arecodeploymentscriptsmanager-1905/hybris/bin/custom/arecosystemsetuptest/resources/updateSystemConfigFile.json | tee updateJunit.log | grep SystemSetupAnnotationCallsTest
ant yunitupdate -DconfigFile=/home/arobirosa/no_backup/areco/arecodeploymentscriptsmanager-1905/hybris/bin/custom/arecosystemsetuptest/resources/updateSystemConfigFile.json | tee yunitUpdate.log | grep SystemSetupAnnotationCallsTest

Source code:

– Based on SAP hybris 1905

1) , 2)
with a JSON configuration to run the project data

Discussion

Enter your comment. Wiki syntax is allowed: