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));
}
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);
}
}
}
Aggregations