Changeset 1643 for trunk/autoquest-plugin-uml-test/src
- Timestamp:
- 08/01/14 16:03:43 (10 years ago)
- Location:
- trunk/autoquest-plugin-uml-test/src/test
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-uml-test/src/test/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtilsTest.java
r1628 r1643 24 24 import java.util.List; 25 25 import java.util.Map; 26 import java.util.Random; 26 27 27 28 import org.eclipse.emf.common.util.URI; … … 36 37 import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 37 38 import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; 39 import org.eclipse.uml2.uml.Interaction; 38 40 import org.eclipse.uml2.uml.Model; 39 41 import org.eclipse.uml2.uml.StateMachine; … … 47 49 import de.ugoe.cs.autoquest.eventcore.Event; 48 50 import de.ugoe.cs.autoquest.plugin.http.HTTPLogParser; 51 import de.ugoe.cs.autoquest.plugin.http.HTTPUtils; 49 52 import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType; 50 53 import de.ugoe.cs.autoquest.plugin.uml.eventcore.UMLTransitionType; 54 import de.ugoe.cs.autoquest.testgeneration.RandomWalkGenerator; 55 import de.ugoe.cs.autoquest.usageprofiles.FirstOrderMarkovModel; 51 56 52 57 /** … … 151 156 HTTPLogParser parser = 152 157 new HTTPLogParser(new File(ClassLoader 153 .getSystemResource("testCreateInteractionFromEventSequence_1_properties.txt").getFile())); 154 parser.parseFile(new File(ClassLoader 155 .getSystemResource("testCreateInteractionFromEventSequence_1_usagedata.log").getFile())); 158 .getSystemResource("testCreateInteractionFromEventSequence_1_properties.txt") 159 .getFile())); 160 parser 161 .parseFile(new File(ClassLoader 162 .getSystemResource("testCreateInteractionFromEventSequence_1_usagedata.log") 163 .getFile())); 156 164 Collection<List<Event>> httpSequences = parser.getSequences(); 157 165 Model model = … … 169 177 UMLUtils.createInteractionFromEventSequence(httpSequence, model, "testSequence"); 170 178 } 171 //writeModelToFile(model, "testCreateInteractionFromEventSequence_1_result.uml"); 179 // writeModelToFile(model, "testCreateInteractionFromEventSequence_1_result.uml"); 180 } 181 182 @Test 183 public void testCalculateUsageScore_1() throws Exception { 184 // parse log file 185 HTTPLogParser parser = 186 new HTTPLogParser(new File(ClassLoader 187 .getSystemResource("testCalculateUsageScore_1_properties.txt").getFile())); 188 parser.parseFile(new File(ClassLoader 189 .getSystemResource("testCalculateUsageScore_1_usagedata.log").getFile())); 190 Collection<List<Event>> httpSequences = parser.getSequences(); 191 Model model = 192 loadModelFromInputStream(ClassLoader 193 .getSystemResourceAsStream("testCalculateUsageScore_1_model.uml")); 194 195 Collection<List<Event>> simpleSOAPSequences = new LinkedList<>(); 196 for (List<Event> httpSequence : httpSequences) { 197 for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) { 198 Event event = eventIter.next(); 199 if (!(event.getType() instanceof SOAPEventType)) { 200 eventIter.remove(); 201 } 202 } 203 simpleSOAPSequences.add(HTTPUtils.convertToSimpleSOAPEvent(httpSequence)); 204 // simpleSOAPSequences.add(httpSequence); 205 } 206 207 FirstOrderMarkovModel usageProfile = new FirstOrderMarkovModel(new Random(1)); 208 usageProfile.train(simpleSOAPSequences); 209 210 Collection<List<Event>> genSeqs = 211 (new RandomWalkGenerator(10, 1, 100, true, 500)).generateTestSuite(usageProfile); 212 213 int i = 1; 214 int[] lengths = new int[genSeqs.size()]; 215 for (List<Event> seq : genSeqs) { 216 UMLUtils.createInteractionFromEventSequence(seq, model, "seq_" + i); 217 lengths[i - 1] = seq.size(); 218 i++; 219 } 220 for (int j = 0; j < genSeqs.size(); j++) { 221 Interaction interaction = 222 (Interaction) model.getPackagedElement("seq_" + j, true, 223 UMLPackage.Literals.INTERACTION, true); 224 double usageScore = UMLUtils.calculateUsageScore(interaction, usageProfile); 225 System.out.format("usage score %02d: %.2f \t %d\n",j+1, usageScore, lengths[j]); 226 } 172 227 } 173 228 … … 181 236 return new XMIResourceImpl(uri) { 182 237 @Override 183 public boolean useUUIDs() 184 { 185 return true; 238 public boolean useUUIDs() { 239 return true; 186 240 } 187 241 }; … … 190 244 191 245 Resource resource = resourceSet.createResource(URI.createURI("binresource")); 192 246 193 247 resource.getContents().add(model); 194 248 FileOutputStream fos; 195 249 File file = new File(filename); 196 if ( file.getParent()!=null) {250 if (file.getParent() != null) { 197 251 file.getParentFile().mkdirs(); 198 252 } -
trunk/autoquest-plugin-uml-test/src/test/resources/testCreateInteractionFromEventSequence_1_model.uml
r1625 r1643 4 4 <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/> 5 5 </packageImport> 6 <packagedElement xmi:type="uml:StateMachine" xmi:id="_O36_UAaaEeS7deEA7EQ5bQ" name="PatientIDBehavior">7 <region xmi:type="uml:Region" xmi:id="_O3-psAaaEeS7deEA7EQ5bQ" name="Region0">8 <transition xmi:type="uml:Transition" xmi:id="_paX4YAacEeS7deEA7EQ5bQ" name="IXSMangementAndQueryInterface.UpdateEntityTraitValues" source="_SnZhwAaaEeS7deEA7EQ5bQ" target="_SnZhwAaaEeS7deEA7EQ5bQ"/>9 <transition xmi:type="uml:Transition" xmi:id="_1hD9YAacEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.RegisterEntityWithIdentity" source="_SnZhwAaaEeS7deEA7EQ5bQ" target="_X7obgAaaEeS7deEA7EQ5bQ"/>10 <transition xmi:type="uml:Transition" xmi:id="_ZbI3sAagEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.CreateIdentityFromEntity" source="_SnZhwAaaEeS7deEA7EQ5bQ" target="_X7obgAaaEeS7deEA7EQ5bQ"/>11 <transition xmi:type="uml:Transition" xmi:id="_hU4bIAagEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.GetEntityTraitValues" source="_SnZhwAaaEeS7deEA7EQ5bQ" target="_SnZhwAaaEeS7deEA7EQ5bQ"/>12 <transition xmi:type="uml:Transition" xmi:id="_AuMAUAahEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.FindIdentitiesByTraits" source="_SnZhwAaaEeS7deEA7EQ5bQ" target="_SnZhwAaaEeS7deEA7EQ5bQ"/>13 <transition xmi:type="uml:Transition" xmi:id="_mnkAQAahEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.RemoveEntity" source="_SnZhwAaaEeS7deEA7EQ5bQ" target="_SnZhwAaaEeS7deEA7EQ5bQ"/>14 <transition xmi:type="uml:Transition" xmi:id="_Bsp-QAaiEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.RegisterEntityWithIdentity" source="_X7obgAaaEeS7deEA7EQ5bQ" target="_X7obgAaaEeS7deEA7EQ5bQ"/>15 <transition xmi:type="uml:Transition" xmi:id="_M3iiUAaiEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.CreateIdentityFromEntity" source="_X7obgAaaEeS7deEA7EQ5bQ" target="_X7obgAaaEeS7deEA7EQ5bQ"/>16 <transition xmi:type="uml:Transition" xmi:id="_TLpksAaiEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.UpdateEntityTraitValues" source="_X7obgAaaEeS7deEA7EQ5bQ" target="_X7obgAaaEeS7deEA7EQ5bQ"/>17 <transition xmi:type="uml:Transition" xmi:id="_WbouwAaiEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.RemoveIdentity" source="_X7obgAaaEeS7deEA7EQ5bQ" target="_SnZhwAaaEeS7deEA7EQ5bQ"/>18 <transition xmi:type="uml:Transition" xmi:id="_36iugAaiEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.GetEntityTraitValues" source="_X7obgAaaEeS7deEA7EQ5bQ" target="_X7obgAaaEeS7deEA7EQ5bQ"/>19 <transition xmi:type="uml:Transition" xmi:id="_BSZ1wAajEeS7deEA7EQ5bQ" name="IXSManagementAndQueryInterface.FindIdentityByTraits" source="_X7obgAaaEeS7deEA7EQ5bQ" target="_X7obgAaaEeS7deEA7EQ5bQ"/>20 <subvertex xmi:type="uml:State" xmi:id="_SnZhwAaaEeS7deEA7EQ5bQ" name="PatientUnkown_MPI_RLUS"/>21 <subvertex xmi:type="uml:State" xmi:id="_X7obgAaaEeS7deEA7EQ5bQ" name="PatientKnown_MPI_PatientUnkown_RLUS"/>22 <subvertex xmi:type="uml:State" xmi:id="_e-D8cAaaEeS7deEA7EQ5bQ" name="PatientKnown_RLUS_PatientUnkown_MPI"/>23 <subvertex xmi:type="uml:State" xmi:id="_a1ERUAabEeS7deEA7EQ5bQ" name="PatientKnown_MPI_RLUS"/>24 </region>25 </packagedElement>26 6 <packagedElement xmi:type="uml:Class" xmi:id="_Wh3rMBZcEeSVxMc4KdphRg" name="ixsmq"> 27 7 <ownedOperation xmi:type="uml:Operation" xmi:id="_noyI0BZcEeSVxMc4KdphRg" name="removeIdentity"/>
Note: See TracChangeset
for help on using the changeset viewer.