Skip to content

Commit

Permalink
Merge pull request #7 from SmartBear/generic-parser-dev
Browse files Browse the repository at this point in the history
ZEPHYR-28000
  • Loading branch information
prashu-upadhyay committed Jan 16, 2020
2 parents 0ef2504 + dd1379b commit d920c74
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/thed/service/TCRCatalogTreeService.java
Expand Up @@ -19,6 +19,14 @@ public interface TCRCatalogTreeService extends BaseService {
*/
List<TCRCatalogTreeDTO> getTCRCatalogTreeNodes(String type, Long releaseId) throws URISyntaxException;

/**
* Get tcrCatalogTree node for given id.
* @param tcrCatalogTreeId
* @return
* @throws URISyntaxException
*/
TCRCatalogTreeDTO getTCRCatalogTreeNode(Long tcrCatalogTreeId) throws URISyntaxException;

/**
* Create a tree node such as phase.
* @param tcrCatalogTreeDTO
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/thed/service/ZephyrRestService.java
Expand Up @@ -79,6 +79,14 @@ public interface ZephyrRestService {
*/
List<TCRCatalogTreeDTO> getTCRCatalogTreeNodes(String type, Long revisionId, Long releaseId) throws URISyntaxException;

/**
* Get tcrCatalogTree node for given id.
* @param tcrCatalogTreeId
* @return
* @throws URISyntaxException
*/
TCRCatalogTreeDTO getTCRCatalogTreeNode(Long tcrCatalogTreeId) throws URISyntaxException;

/**
* Create a tree node such as phase.
* @param tcrCatalogTreeDTO
Expand Down
Expand Up @@ -21,6 +21,11 @@ public List<TCRCatalogTreeDTO> getTCRCatalogTreeNodes(String type, Long releaseI
return zephyrRestService.getTCRCatalogTreeNodes(type, 0l, releaseId);
}

@Override
public TCRCatalogTreeDTO getTCRCatalogTreeNode(Long tcrCatalogTreeId) throws URISyntaxException {
return zephyrRestService.getTCRCatalogTreeNode(tcrCatalogTreeId);
}

@Override
public TCRCatalogTreeDTO createTCRCatalogTreeNode(TCRCatalogTreeDTO tcrCatalogTreeDTO) throws URISyntaxException {
return zephyrRestService.createTCRCatalogTreeNode(tcrCatalogTreeDTO);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/thed/service/impl/ZephyrRestServiceImpl.java
Expand Up @@ -31,6 +31,7 @@ public class ZephyrRestServiceImpl implements ZephyrRestService {
public static final String GET_ALL_RELEASES_FOR_PROJECT_ID_URL = "/flex/services/rest/{restVersion}/release/paged/project/{projectId}"; //?order=id&isascorder=true&isVisible=false

public static final String GET_TCR_CATALOG_TREE_NODES_URL = "/flex/services/rest/{restVersion}/testcasetree"; //?type=Phase&revisionid=0&releaseid=10
public static final String GET_TCR_CATALOG_TREE_NODE_URL = "/flex/services/rest/{restVersion}/testcasetree/{tcrCatalogTreeId}";
public static final String CREATE_TCR_CATALOG_TREE_NODE_URL = "/flex/services/rest/{restVersion}/testcasetree"; //?parentid=0

public static final String MAP_TESTCASE_TO_REQUIREMENTS_URL = "/flex/services/rest/v3/requirement/bulk";
Expand Down Expand Up @@ -200,6 +201,7 @@ public List<Cycle> getAllCyclesForReleaseId(Long releaseId) throws URISyntaxExce
return gson.fromJson(res, releaseListType);
}

@Override
public List<TCRCatalogTreeDTO> getTCRCatalogTreeNodes(String type, Long revisionId, Long releaseId) throws URISyntaxException {
List<NameValuePair> queryParams = new ArrayList<>();
queryParams.add(new BasicNameValuePair("type", type));
Expand All @@ -213,6 +215,17 @@ public List<TCRCatalogTreeDTO> getTCRCatalogTreeNodes(String type, Long revision
return gson.fromJson(res, tcrCatalogTreeListType);
}

@Override
public TCRCatalogTreeDTO getTCRCatalogTreeNode(Long tcrCatalogTreeId) throws URISyntaxException {
Map<String, String> pathParams = new HashMap<>();
pathParams.put("tcrCatalogTreeId", tcrCatalogTreeId.toString());

String url = buildUrl(prepareUrl(GET_TCR_CATALOG_TREE_NODE_URL), pathParams, null);
String res = httpClientService.getRequest(url);

return gson.fromJson(res, TCRCatalogTreeDTO.class);
}

@Override
public TCRCatalogTreeDTO createTCRCatalogTreeNode(TCRCatalogTreeDTO tcrCatalogTreeDTO) throws URISyntaxException {
List<NameValuePair> queryParams = new ArrayList<>();
Expand Down
Expand Up @@ -396,6 +396,11 @@ public ListBoxModel doFillParserIndexItems() {
listBoxModel.add("Cucumber", "1");
listBoxModel.add("TestNG", "2");
listBoxModel.add("Eggplant", "3");
listBoxModel.add("Selenium", "4");
listBoxModel.add("TestComplete", "5");
listBoxModel.add("SoapUI", "6");
listBoxModel.add("Tosca", "7");
listBoxModel.add("UFT", "8");
return listBoxModel;
}

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/thed/zephyr/jenkins/reporter/ZeeReporter.java
Expand Up @@ -121,7 +121,12 @@ public boolean perform(final Run build, final TaskListener listener) throws IOEx
"[{ \"status\": \"$testsuite.testcase.failure\", \"statusExistPass\": false, \"statusString\": null, \"statusFailAttachment\": \"$testsuite.testcase.failure\", \"statusPassAttachment\": \"classname: $testsuite.testcase:classname \nname: $testsuite.testcase:name \ntime: $testsuite.testcase:time\", \"packageName\": \"$testsuite.testcase:classname\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}], \"attachments\": [{\"filePath\": \"$testsuite.testcase.attachments.attachment\"}]}]",//junit
"[{ \"status\": \"\", \"system-out\": \"$testsuite.testcase.system-out\", \"statusExistPass\": false, \"statusString\": null, \"statusFailAttachment\": \"\", \"statusPassAttachment\": \"classname: $testsuite.testcase:classname \nname: $testsuite.testcase:name \ntime: $testsuite.testcase:time\", \"packageName\": \"$testsuite.testcase:classname\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}], \"attachments\": [{\"filePath\": \"$testsuite.testcase.attachments.attachment\"}]}]", //cucumber
"[{ \"status\": \"$testng-results.suite.test.class.test-method:status\", \"statusExistPass\": true, \"statusString\": \"PASS\", \"packageName\": \"$testng-results.suite.test.class:name\", \"skipTestcaseNames\": \"afterMethod,beforeMethod,afterClass,beforeClass,afterSuite,beforeSuite\", \"testcase\" : {\"name\": \"$testng-results.suite.test.class.test-method:name\"}}]", //testng
"[{ \"status\": \"$testsuite.testcase:successes\", \"statusExistPass\": true, \"statusString\": \"1\", \"packageName\": \"$testsuite:name\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}]}]"//eggplant
"[{ \"status\": \"$testsuite.testcase:successes\", \"statusExistPass\": true, \"statusString\": \"1\", \"packageName\": \"$testsuite:name\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}]}]", //eggplant
"[{ \"status\": \"$testsuite.testcase.failure\", \"statusExistPass\": false, \"statusString\": null, \"statusFailAttachment\": \"$testsuite.testcase.failure\", \"statusPassAttachment\": \"classname: $testsuite.testcase:classname \nname: $testsuite.testcase:name \ntime: $testsuite.testcase:time\", \"packageName\": \"$testsuite.testcase:classname\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}], \"attachments\": [{\"filePath\": \"$testsuite.testcase.attachments.attachment\"}]}]",//selenium
"[{ \"status\": \"\", \"system-out\": \"$testsuite.testcase.system-out\", \"statusExistPass\": false, \"statusString\": null, \"statusFailAttachment\": \"\", \"statusPassAttachment\": \"classname: $testsuite.testcase:classname \nname: $testsuite.testcase:name \ntime: $testsuite.testcase:time\", \"packageName\": \"$testsuite.testcase:classname\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}], \"attachments\": [{\"filePath\": \"$testsuite.testcase.attachments.attachment\"}]}]", //testcomplete
"[{ \"status\": \"$testsuite.testcase.failure\", \"statusExistPass\": false, \"statusString\": null, \"statusFailAttachment\": \"$testsuite.testcase.failure\", \"statusPassAttachment\": \"name: $testsuite.testcase:name \ntime: $testsuite.testcase:time\", \"packageName\": \"$testsuite:name\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}], \"attachments\": [{\"filePath\": \"$testsuite.testcase.attachments.attachment\"}]}]",//soapui
"[{ \"status\": \"$testsuite.testcase.failure\", \"statusExistPass\": false, \"statusString\": null, \"statusFailAttachment\": \"$testsuite.testcase.failure\", \"statusPassAttachment\": \"name: $testsuite.testcase:name \ntime: $testsuite.testcase:time \ntimestamp: $testsuite.testcase:timestamp \nlog: $testsuite.testcase:log \", \"packageName\": \"$testsuite:name\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}], \"attachments\": [{\"filePath\": \"$testsuite.testcase.attachments.attachment\"}]}]",//tosca
"[{ \"status\": \"$testsuite.testcase.failure:message\", \"statusExistPass\": false, \"statusString\": null, \"statusFailAttachment\": \"$testsuite.testcase.failure:message\", \"statusPassAttachment\": \"name: $testsuite.testcase:name \nreport: $testsuite.testcase:report \ntime: $testsuite.testcase:time \nclassname: $testsuite.testcase:classname \nstatus: $testsuite.testcase:status \", \"packageName\": \"$testsuite:package\" , \"skipTestcaseNames\": \"\", \"testcase\" : {\"name\": \"$testsuite.testcase:name\"}, \"requirements\": [{\"id\": \"$testsuite.testcase.requirements.requirement\"}], \"attachments\": [{\"filePath\": \"$testsuite.testcase.attachments.attachment\"}]}]"//uft
};

if (!validateBuildConfig()) {
Expand Down Expand Up @@ -374,8 +379,10 @@ private Map<String, TCRCatalogTreeDTO> createPackagePhaseMap(ZephyrConfigModel z
for(String packageName : packageNames) {

String[] packageNameArr = packageName.split("\\.");
//todo: make hierarchy locally instead of these extra rest calls
automationPhase = tcrCatalogTreeService.getTCRCatalogTreeNode(automationPhase.getId()); //To refresh child nodes already created in the loop below
TCRCatalogTreeDTO endingNode = automationPhase; //This node is where testcases will be created, it is the last node to be created in this package hierarchy

createPhase = false;
for (int i = 0; i < packageNameArr.length; i++) {
String pName = packageNameArr[i];

Expand Down

0 comments on commit d920c74

Please sign in to comment.