Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How can I create testplan from oslc4j using templates in QM?

Using oslc(QM) I did not find example which includes creation of testplan. Could you please provide example using testplan templates?


Test case example with oslc?

0 votes



One answer

Permanent link
I think, I solved templated issue but I have some problem at required fields.

        // get the URL of the OSLC ChangeManagement service from the rootservices document

            String catalogUrl = client.getCatalogUrl(rqmProperties.getWebContextUrl(), OSLCConstants.OSLC_QM_V2);
        
// find the OSLC Service Provider for the project area we want to work with URI uri = URI.create(testPlanRequest.getProjectAreaName().replaceAll(" ", "%20")); String serviceProviderUrl = client.lookupServiceProviderUrl(catalogUrl, uri.getPath());
String projectId = serviceProviderUrl.substring(0, serviceProviderUrl.lastIndexOf("/")); projectId = projectId.substring(projectId.lastIndexOf("/") + 1);
//Get the Creation Factory URL for test cases so that we can create a test case String oslcTestPlanType = (new TestPlan()).getRdfTypes()[0].toString(); String testPlanFactory = client.lookupCreationFactory(serviceProviderUrl, OSLCConstants.OSLC_QM_V2, oslcTestPlanType);

// We need to use Resource shapes to properly handle date attributes attributes, // so they aren't interpreted as dateTime. // The following 4 lines will enable the logic to properly handle date attributes List<ResourceShape> shapes = new ArrayList<ResourceShape>(); //shapes.add(featureInstanceShape); OSLC4JUtils.setShapes(shapes); OSLC4JUtils.setInferTypeFromShape("true");
TestPlan testPlan = null; if((testPlanFactory == null )){
throw new Exception("testPlanFactory can not be null"); } else {
// initialize test plan
testPlan = new TestPlan();
testPlan.setTitle(testPlanRequest.getTitle());

// set teamArea
QName teamAreaQName = new QName("http://jazz.net/ns/process#", "teamArea", "process");
URI teamAreaUri = new URI("https://...:.../qm/process/team-areas/_qsWPYSCYEeWbKqGgOKE7Vw");
testPlan.getExtendedProperties().put(teamAreaQName, teamAreaUri);

// set template
QName templateQName = new QName("http://jazz.net/ns/qm/rqm#", "template", "rqm_qm");
URI templateUri = new URI("https://...:.../qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Test+ve+Kalite+Y%C3%B6netimi+%28RQMDev%29/template/testplan/com.ibm.rqm.planning.templates.testplan.template_1435832514936");
testPlan.getExtendedProperties().put(teamAreaQName, templateUri);

// create the test plan
Response creationResponse = client.createResource(testPlanFactory, testPlan, OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML);
if(creationResponse.getStatus() != 201)
throw new Exception("Error :" + creationResponse.getStatusInfo());
String reqUrl = creationResponse.getStringHeaders().getFirst(HttpHeaders.LOCATION);
creationResponse.readEntity(String.class);
// check that everything was properly created
if (reqUrl == null) {
throw new Exception("Failed to create an artifact");
}else {
return testPlan;
} }

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 198
× 48
× 17
× 12

Question asked: May 15 '20, 9:44 a.m.

Question was seen: 1,380 times

Last updated: May 15 '20, 11:22 a.m.

Confirmation Cancel Confirm