use of com.hp.octane.integrations.dto.entities.EntityList in project octane-ci-java-sdk by MicroFocus.
the class UftDiscoveryResultDispatcherImpl method postTests.
private boolean postTests(EntitiesService entitiesService, List<AutomatedTest> tests, String workspaceId, String scmRepositoryId, String testRunnerId) {
if (!tests.isEmpty()) {
// convert to DTO
List<Entity> testsForPost = new ArrayList<>(tests.size());
Entity uftTestingTool = createListNodeEntity("list_node.testing_tool_type.uft");
Entity uftFramework = createListNodeEntity("list_node.je.framework.uft");
Entity guiTestType = createListNodeEntity("list_node.test_type.gui");
Entity apiTestType = createListNodeEntity("list_node.test_type.api");
Entity scmRepository = dtoFactory.newDTO(Entity.class).setType(EntityConstants.ScmRepository.ENTITY_NAME).setId(scmRepositoryId);
Entity testRunner = SdkStringUtils.isNotEmpty(testRunnerId) ? dtoFactory.newDTO(Entity.class).setType(EntityConstants.Executors.ENTITY_NAME).setId(testRunnerId) : null;
for (AutomatedTest test : tests) {
Entity testType = UftTestType.API.equals(test.getUftTestType()) ? apiTestType : guiTestType;
EntityList testTypeList = dtoFactory.newDTO(EntityList.class).addEntity(testType);
Entity octaneTest = dtoFactory.newDTO(Entity.class).setType(EntityConstants.AutomatedTest.ENTITY_NAME).setField(EntityConstants.AutomatedTest.TESTING_TOOL_TYPE_FIELD, uftTestingTool).setField(EntityConstants.AutomatedTest.FRAMEWORK_FIELD, uftFramework).setField(EntityConstants.AutomatedTest.TEST_TYPE_FIELD, testTypeList).setField(EntityConstants.AutomatedTest.SCM_REPOSITORY_FIELD, scmRepository).setField(EntityConstants.AutomatedTest.NAME_FIELD, test.getName()).setField(EntityConstants.AutomatedTest.PACKAGE_FIELD, test.getPackage()).setField(EntityConstants.AutomatedTest.DESCRIPTION_FIELD, test.getDescription()).setField(EntityConstants.AutomatedTest.EXECUTABLE_FIELD, test.getExecutable());
testsForPost.add(octaneTest);
if (testRunner != null) {
octaneTest.setField(EntityConstants.AutomatedTest.TEST_RUNNER_FIELD, testRunner);
}
}
// POST
for (int i = 0; i < testsForPost.size(); i += POST_BULK_SIZE) {
try {
List<Entity> subList = testsForPost.subList(i, Math.min(i + POST_BULK_SIZE, testsForPost.size()));
entitiesService.postEntities(Long.parseLong(workspaceId), EntityConstants.AutomatedTest.COLLECTION_NAME, subList);
} catch (OctaneBulkException e) {
return checkIfExceptionCanBeIgnoredInPOST(e, "Failed to post tests");
}
}
}
return true;
}
Aggregations