Changeset 1977
- Timestamp:
- 06/24/15 13:34:41 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtils.java
r1932 r1977 454 454 for (Property property : fetchAllTestComponentProperties(testContext)) { 455 455 // TODO check if this is still required 456 if (userLifeline != null) {456 /*if (userLifeline != null) { 457 457 throw new RuntimeException( 458 458 "TestContext must only have one TestComponent for the application of usage-based testing."); 459 } 459 }*/ 460 460 userLifeline = interaction.createLifeline(property.getName()); 461 461 userLifeline.setRepresents(property); … … 475 475 String methodName = SOAPUtils.getCalledMethodFromEvent(event); 476 476 String clientName = SOAPUtils.getClientNameFromEvent(event); 477 String prefix = interactionName + " :" + i + ":" + methodName + "_";477 String prefix = interactionName + "_" + i + "_" + methodName + "_"; 478 478 // determine lifelines 479 479 Lifeline msgTargetLifeline; … … 1036 1036 Package instSpecPkg = null; 1037 1037 1038 // FOR DEBUGGING 1039 // Console.traceln(Level.FINE, "XML structure of path:" + StringTools.ENDLINE + 1040 // SOAPUtils.getSerialization(requestBody)); 1041 // for( Parameter param : calledOperation.getOwnedParameters() ) { 1042 // System.out.println(param.getName()); 1043 // if( param.getType() instanceof DataType ) { 1044 // for( Property prop1 : ((DataType) param.getType()).getAllAttributes() ) { 1045 // System.out.println(" " + prop1.getName()); 1046 // if( prop1.getType() instanceof DataType ) { 1047 // for( Property prop2 : ((DataType) prop1.getType()).getAllAttributes() ) { 1048 // System.out.println(" " + prop2.getName()); 1049 // if( prop2.getType() instanceof DataType ) { 1050 // for( Property prop3 : ((DataType) prop2.getType()).getAllAttributes() ) { 1051 // System.out.println(" " + prop3.getName()); 1052 // if( prop3.getType() instanceof DataType ) { 1053 // for( Property prop4 : ((DataType) prop3.getType()).getAllAttributes() ) { 1054 // System.out.println(" " + prop4.getName()); 1055 // } 1056 // } 1057 // } 1058 // } 1059 // } 1060 // } 1061 // } 1062 // } 1063 // } 1064 1038 1065 // Set parameters of operation 1039 1066 for (Parameter param : calledOperation.getOwnedParameters()) { 1040 1067 if (instSpecPkg == null) { 1041 instSpecPkg = getOrCreateInstanceSpecificationPackage(param.getModel(), event); 1042 } 1043 1044 String path = calledOperation.getName() + ":" + param.getName(); 1068 instSpecPkg = getOrCreateInstanceSpecificationPackage(callMessage.getModel(), event); 1069 } 1070 1071 // TODO String path = calledOperation.getName() + ":" + param.getName(); 1072 String path = calledOperation.getName() + ":" + param.getType().getName(); 1073 // create param node 1045 1074 Expression argument = 1046 1075 (Expression) callMessage.createArgument(param.getName(), param.getType(), … … 1048 1077 1049 1078 if (isInParameter(param)) { 1050 if (param.getType() instanceof DataType) { 1051 List<org.w3c.dom.Element> paramNodes = 1052 SOAPUtils.getMatchingChildNode(param.getType().getName(), requestBody); 1053 int multiplicityChosen = paramNodes.size(); 1054 1055 if (multiplicityChosen == 0 && param.getLower() > 0) { 1056 Console.traceln(Level.WARNING, 1057 "required attribute not found in SOAP message: " + path); 1058 Console 1059 .traceln(Level.WARNING, 1060 "setting default values for this attribute and all its children"); 1061 Console.traceln(Level.FINE, "XML structure of path:" + StringTools.ENDLINE + 1062 SOAPUtils.getSerialization(requestBody)); 1063 multiplicityChosen = param.getLower(); 1079 1080 // create parameters node 1081 if (!(param.getType() instanceof DataType) ) { 1082 throw new RuntimeException("TODO error handling; parameters missing"); 1083 } 1084 DataType parametersNode = (DataType) param.getType(); 1085 InstanceSpecification instSpecParameters = (InstanceSpecification) 1086 instSpecPkg.createPackagedElement(prefix + "instspec_" + param.getType().getName(), 1087 UMLPackage.Literals.INSTANCE_SPECIFICATION); 1088 instSpecParameters.getClassifiers().add((DataType) param.getType()); 1089 InstanceValue parametersValue = 1090 (InstanceValue) argument 1091 .createOperand(param.getType().getName(), param.getType(), 1092 UMLPackage.Literals.INSTANCE_VALUE); 1093 parametersValue.setInstance(instSpecParameters); 1094 1095 for( Property internalParameter : parametersNode.getAllAttributes() ) { 1096 if (internalParameter.getType() instanceof DataType) { 1097 List<org.w3c.dom.Element> paramNodes = 1098 SOAPUtils.getMatchingChildNode(internalParameter.getType().getName(), requestBody); 1099 // TODO the mistake is somewhere around here ... probably 1100 //List<org.w3c.dom.Element> paramNodes = 1101 // SOAPUtils.getMatchingChildNode(param.getName(), requestBody); 1102 int multiplicityChosen = paramNodes.size(); 1103 1104 if (multiplicityChosen == 0 && internalParameter.getLower() > 0) { 1105 Console.traceln(Level.WARNING, 1106 "required attribute not found in SOAP message: " + path); 1107 Console 1108 .traceln(Level.WARNING, 1109 "setting default values for this attribute and all its children"); 1110 Console.traceln(Level.FINE, "XML structure of path:" + StringTools.ENDLINE + 1111 SOAPUtils.getSerialization(requestBody)); 1112 multiplicityChosen = internalParameter.getLower(); 1113 } 1114 for (int i = 0; i < multiplicityChosen; i++) { 1115 org.w3c.dom.Element paramNode = null; 1116 if (!paramNodes.isEmpty()) { 1117 paramNode = paramNodes.get(i); 1118 } 1119 1120 Slot slot = instSpecParameters.createSlot(); 1121 slot.setDefiningFeature(internalParameter); 1122 1123 InstanceValue value = 1124 (InstanceValue) slot.createValue(internalParameter.getName() + "_" + i, internalParameter.getType(), 1125 UMLPackage.Literals.INSTANCE_VALUE); 1126 value.setInstance(createInstanceSpecification((DataType) internalParameter.getType(), instSpecPkg, 1127 prefix, paramNode, path)); 1128 /* 1129 InstanceValue value = 1130 (InstanceValue) argument 1131 .createOperand(null, internalParameter.getType(), 1132 UMLPackage.Literals.INSTANCE_VALUE); 1133 value.setInstance(instSpec);*/ 1134 } 1064 1135 } 1065 for (int i = 0; i < multiplicityChosen; i++) { 1066 org.w3c.dom.Element paramNode = null; 1067 if (!paramNodes.isEmpty()) { 1068 paramNode = paramNodes.get(i); 1069 } 1070 InstanceSpecification instSpec = 1071 createInstanceSpecification((DataType) param.getType(), instSpecPkg, 1072 prefix, paramNode, path); 1073 1074 InstanceValue value = 1075 (InstanceValue) argument 1076 .createOperand(null, param.getType(), 1077 UMLPackage.Literals.INSTANCE_VALUE); 1078 value.setInstance(instSpec); 1136 else if (internalParameter.getType() instanceof PrimitiveType) { 1137 createSlotPrimitiveType(instSpecParameters, internalParameter, requestBody, path); 1079 1138 } 1080 }1081 else if (param.getType() instanceof PrimitiveType) {1082 createOperandPrimitiveType(param, argument, requestBody, path);1083 1139 } 1084 1140 } … … 1133 1189 int multiplicityChosen = 0; 1134 1190 if (currentNode != null) { 1191 // TODO attributeNodes = SOAPUtils.getMatchingChildNode(prop.getName(), currentNode); 1135 1192 attributeNodes = SOAPUtils.getMatchingChildNode(prop.getName(), currentNode); 1136 1193 multiplicityChosen = attributeNodes.size(); … … 1408 1465 argument.createOperand(null, param.getType(), UMLPackage.Literals.LITERAL_NULL); 1409 1466 if (isOutParameter(param)) { 1410 operand.applyStereotype(UTPUtils.getLiteralAnyStereotype( param.getModel()));1467 operand.applyStereotype(UTPUtils.getLiteralAnyStereotype(replyMessage.getModel())); 1411 1468 } 1412 1469 }
Note: See TracChangeset
for help on using the changeset viewer.