Search in sources :

Example 1 with MbtData

use of com.hp.octane.integrations.dto.general.MbtData in project octane-ci-java-sdk by MicroFocus.

the class MbtTests method parseConfiguration.

@Test
public void parseConfiguration() {
    URL url = getClass().getResource("mbtExample1.json");
    MbtData mbtData = DTOFactory.getInstance().dtoFromJsonFile(new File(url.getFile()), MbtData.class);
    Assert.assertEquals(4, mbtData.getUnits().size());
    Assert.assertEquals(6, mbtData.getData().getParameters().size());
    Assert.assertEquals(2, mbtData.getData().getIterations().size());
    mbtData.getData().getIterations().forEach(strings -> Assert.assertEquals(6, strings.size()));
    mbtData.getUnits().forEach(mbtUnit -> System.out.println(mbtUnit.getName() + ", parameters: " + Optional.ofNullable(mbtUnit.getParameters()).orElse(Collections.emptyList()).stream().map(MbtUnitParameter::getParameterId).collect(Collectors.joining(", "))));
    mbtData.getData().getParameters().forEach(System.out::println);
    mbtData.getData().getIterations().forEach(strings -> strings.forEach(System.out::println));
}
Also used : MbtData(com.hp.octane.integrations.dto.general.MbtData) File(java.io.File) URL(java.net.URL) MbtUnitParameter(com.hp.octane.integrations.dto.general.MbtUnitParameter) Test(org.junit.Test)

Example 2 with MbtData

use of com.hp.octane.integrations.dto.general.MbtData in project octane-ci-java-sdk by MicroFocus.

the class MfMBTConverter method handleMBTModel.

private void handleMBTModel(List<TestToRunData> tests, String checkoutFolder, Map<String, String> globalParameters) {
    // replace test name if required
    for (TestToRunData data : tests) {
        data.setTestName(encodeTestNameIfRequired(data.getTestName()));
    }
    mbtTests = new ArrayList<>();
    int order = 1;
    for (TestToRunData data : tests) {
        String mbtDataRaw = data.getParameter(MBT_DATA);
        MbtData mbtData;
        if (MBT_DATA_NOT_INCLUDED.equals(mbtDataRaw)) {
            throw new RuntimeException("Failed to fetch mbt data for test " + data.getTestName());
        }
        try {
            String raw = new String(Base64.getDecoder().decode(mbtDataRaw), StandardCharsets.UTF_8);
            mbtData = DTOFactory.getInstance().dtoFromJson(raw, MbtData.class);
            if (mbtData.getTestingToolType().equals(TestingToolType.UFT)) {
                // advance package name only for uft tests. it is not relevant for codeless tests
                data.setPackageName("_" + order++);
            }
        } catch (Exception e) {
            String msg = "Failed to decode test action data " + data.getTestName() + " : " + e.getMessage();
            logger.error(msg);
            throw new RuntimeException(msg);
        }
        if (mbtData.getTestingToolType().equals(TestingToolType.UFT)) {
            convertUftTest(checkoutFolder, data, mbtData);
        } else {
            convertCodelessTest(data, mbtData);
        }
    }
}
Also used : MbtData(com.hp.octane.integrations.dto.general.MbtData) TestToRunData(com.hp.octane.integrations.executor.TestToRunData) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

MbtData (com.hp.octane.integrations.dto.general.MbtData)2 MbtUnitParameter (com.hp.octane.integrations.dto.general.MbtUnitParameter)1 TestToRunData (com.hp.octane.integrations.executor.TestToRunData)1 File (java.io.File)1 URL (java.net.URL)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Test (org.junit.Test)1 SAXException (org.xml.sax.SAXException)1