It's all about the answers!

Ask a question

RQM: how to read Test case category attributes values from extended properties through OSLC


Naveen Tyagi (19778152) | asked Apr 05 '17, 7:13 a.m.

Hi All,
I am trying to read the category value of Test case through OSLC but after looping through to extended values for category i am getting An array of the URI. Can anyone help me to get the attributes values from URI. I have tried using AnyResource but it can not cast to URI.
public void getExtendedProperties(TestCase testCase)

{
Map<String,String> testCaseAttributes = new HashMap<String, String>();
for (Entry<QName, Object> extendedProperty : testCase.getExtendedProperties().entrySet()) {
if("category".equalsIgnoreCase(extendedProperty.getKey().getLocalPart())) { 
//System.out.println("Key :" +extendedProperty.getKey()  + " Value : " + extendedProperty.getValue());
Object value = extendedProperty.getValue();
if(value instanceof ArrayList<?>){
ArrayList<?> extendedProp = (ArrayList<?>) value;
//System.out.println("we are getting category value : " );
for(int i = 0; i< extendedProp. size(); i++){
AnyResource resources = (AnyResource) extendedProp.get(i); // Getting URI and can not Cast to AnyResource.
String categoryName = "";
String categoryValue = "";
for (Entry<QName, Object> resource : resources.getExtendedProperties().entrySet()) {
if("title".equalsIgnoreCase(resource.getKey().getLocalPart())){
categoryName = resource.getValue().toString();
}else if("subject".equalsIgnoreCase(resource.getKey().getLocalPart())){
categoryValue =  resource.getValue().toString();
}
}
testCaseAttributes.put(categoryName, categoryValue);
}
}
}
}

One answer



permanent link
Donald Nong (14.5k614) | answered Apr 07 '17, 2:13 a.m.

The category in a test case looks like this in the XML output.

<ns2:category term="Test Phase" value="Integration Test"/>
What do you mean that you get "an array of the URI"?

Your answer


Register or 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.