Интеграционный тест на базе S4 SDK VDM не проходит во время сборки maven - PullRequest
1 голос
/ 13 июня 2019

Я использовал S4SDK VDM в своем интеграционном тестировании для тестирования своих служб ODATA. Во время реализации были некоторые проблемы, и Александр даровал мне, чтобы все заработало. ( VDM для интеграционных тестов )

Когда я выполнил JUnit в затмении, он работает хорошо. Однако, когда JUnit работает во время сборки / в Maven, он завершается с ошибкой ниже

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   BusinessServiceIT.createBusinessService:132->createLandscapeObject:214 » ErpOData
[INFO] 
[ERROR] Tests run: 21, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:34 min
[INFO] Finished at: 2019-06-13T16:00:26+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project x-srv-landscapeManagement-integration-tests: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Users\xxxxx\git\x-service-landscapeManagement\srv\integration-tests\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :x-srv-landscapeManagement-integration-tests
    public static void beforeClass() {
        mockUtil.mockDefaults();
        mockUtil.mockAuditLog();

        lsoCreateHelper.withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();
        connectionHelper.withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();

    }```

``` @Before
    public void beforeEach() throws URISyntaxException, IOException, ODataException {
        mockUtil.mockDestination("localhorst", new URI("http://localhost:" + randomServerPort));
        erpConfCtx = new ErpConfigContext("localhorst");
        final String publicKey = FileUtils.readFile("publicKey.txt");
        final Map<String, String> verificationkey = ImmutableMap.of("verificationkey", publicKey);
        final JsonObject xsuaaServiceCredentials = new Gson().toJsonTree(verificationkey).getAsJsonObject();
        when(((ScpCfCloudPlatform) CloudPlatformAccessor.getCloudPlatform())
                .getXsuaaServiceCredentials(org.mockito.ArgumentMatchers.any(DecodedJWT.class)))
                        .thenReturn(xsuaaServiceCredentials);
    }```

private UUID createLandscapeObject(String lsoType, String name, String customerNumber, String source,
        String usecase, String tenantId, String tenantType) throws ODataException {
    Properties properties = new Properties();
    List<Properties> propertySet = new ArrayList<>();

    if (usecase != null) {
        properties.setName("useCase");
        properties.setValue(usecase);
        properties.setSource(source);
        propertySet.add(properties);
    }

    if (tenantId != null) {
        propertySet = new ArrayList<>();
        properties.setName("TenantId");
        properties.setValue(tenantId);
        properties.setSource(source);
        propertySet.add(properties);
    }

    if (tenantType != null) {
        propertySet = new ArrayList<>();
        properties.setName("TenantType");
        properties.setValue(tenantType);
        properties.setSource(source);
        propertySet.add(properties);
    }

    LandscapeObjects landscapeObjects = new LandscapeObjects(null, null, null, null, null, name, "benufromit_test",
            lsoType, customerNumber, source, null, null, propertySet);
    LOG.info("benu-business1");

    final LandscapeObjectsCreateFluentHelper lsoCreateHelper = lmsService.createLandscapeObjects(landscapeObjects)
            .withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();

    landscapeObjects = lsoCreateHelper.execute(erpConfCtx);
    return landscapeObjects.getId();

}```

[ОШИБКА] Ошибки: [ОШИБКА] BusinessServiceIT.createBusinessService: 132-> createLandscapeObject: 214 »ErpOData

target \ surefire-reports

-------------------------------------------------------------------------------
Test set: com.sap.crun.landscape.BusinessServiceIT
-------------------------------------------------------------------------------
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 66.107 s <<< FAILURE! - in com.sap.crun.landscape.BusinessServiceIT
createBusinessService(com.sap.crun.landscape.BusinessServiceIT)  Time elapsed: 2.463 s  <<< ERROR!
com.sap.cloud.sdk.s4hana.datamodel.odata.helper.ODataVdmErrorResultHandler$ErpODataException: 
The endpoint responded with HTTP error code 500.
. . 
Full error message: 
<?xml version='1.0' encoding='UTF-8'?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code/><message xml:lang="en">Service not available: LandscapeService.</message></error>
    at com.sap.crun.landscape.BusinessServiceIT.createLandscapeObject(BusinessServiceIT.java:214)
    at com.sap.crun.landscape.BusinessServiceIT.createBusinessService(BusinessServiceIT.java:132)```


**TestApplication**

package com.sap.crun.landscape;

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.web.servlet.ServletComponentScan;
    import org.springframework.context.annotation.ComponentScan;

    @SpringBootApplication
    @ComponentScan(basePackages = {"com.sap.cloud.servicesdk.spring", "com.sap.crun.landscape"})
    @ServletComponentScan( "com.sap.cloud.sdk" )
    public class TestApplication {
        public static void main(String[] args) {
            SpringApplication.run(TestApplication.class, args);
        }
    }



...