1818import org .utbot .examples .manual .examples .customer .C ;
1919import org .utbot .examples .manual .examples .customer .Demo9 ;
2020import org .utbot .external .api .TestMethodInfo ;
21+ import org .utbot .external .api .UnitTestBotLight ;
2122import org .utbot .external .api .UtBotJavaApi ;
2223import org .utbot .external .api .UtModelFactory ;
2324import org .utbot .framework .codegen .domain .ForceStaticMocking ;
@@ -1306,7 +1307,16 @@ public void testFuzzingSimple() {
13061307
13071308 @ NotNull
13081309 private String getClassPath (Class <?> clazz ) {
1309- return clazz .getProtectionDomain ().getCodeSource ().getLocation ().getPath ();
1310+ try {
1311+ return normalizePath (clazz .getProtectionDomain ().getCodeSource ().getLocation ());
1312+ } catch (URISyntaxException e ) {
1313+ throw new RuntimeException (e );
1314+ }
1315+ }
1316+
1317+ @ NotNull
1318+ private String normalizePath (URL url ) throws URISyntaxException {
1319+ return new File (url .toURI ()).getPath ();
13101320 }
13111321
13121322 @ NotNull
@@ -1376,4 +1386,37 @@ public UtCompositeModel createArrayOfComplexArraysModel() {
13761386 classIdOfArrayOfComplexArraysClass ,
13771387 Collections .singletonMap ("array" , arrayOfComplexArrayClasses ));
13781388 }
1389+
1390+ @ Test
1391+ public void testUnitTestBotLight () {
1392+ String classpath = getClassPath (Trivial .class );
1393+ String dependencyClassPath = getDependencyClassPath ();
1394+
1395+ UtCompositeModel model = modelFactory .
1396+ produceCompositeModel (
1397+ classIdForType (Trivial .class )
1398+ );
1399+
1400+ EnvironmentModels environmentModels = new EnvironmentModels (
1401+ model ,
1402+ Collections .singletonList (new UtPrimitiveModel (2 )),
1403+ Collections .emptyMap ()
1404+ );
1405+
1406+ Method methodUnderTest = PredefinedGeneratorParameters .getMethodByName (
1407+ Trivial .class ,
1408+ "aMethod" ,
1409+ int .class
1410+ );
1411+
1412+ UnitTestBotLight .run (
1413+ (engine , state ) -> System .err .println ("Got a call:" + state .getStmt ()),
1414+ new TestMethodInfo (
1415+ methodUnderTest ,
1416+ environmentModels
1417+ ),
1418+ classpath ,
1419+ dependencyClassPath
1420+ );
1421+ }
13791422}
0 commit comments