File tree Expand file tree Collapse file tree 3 files changed +15
-14
lines changed
utbot-framework-test/src/test/kotlin/org/utbot/examples/stream
utbot-framework/src/main/kotlin/org/utbot/engine
utbot-sample/src/main/java/org/utbot/examples/stream Expand file tree Collapse file tree 3 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -343,14 +343,13 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
343343 }
344344
345345 @Test
346- @Disabled(" TODO unsat type constraints https://github.com/UnitTestBot/UTBotJava/issues/253" )
347346 fun testCustomCollectionStreamExample () {
348347 check(
349348 BaseStreamExample ::customCollectionStreamExample,
350349 ignoreExecutionsNumber,
351350 { c, r -> c.isEmpty() && r == 0L },
352351 { c, r -> c.isNotEmpty() && c.size.toLong() == r },
353- coverage = DoNotCalculate
352+ coverage = DoNotCalculate // TODO failed coverage calculation
354353 )
355354 }
356355
Original file line number Diff line number Diff line change @@ -2344,8 +2344,15 @@ class Traverser(
23442344 // for objects (especially objects with type equals to type parameter of generic)
23452345 // better than engine.
23462346 val types = instanceOfConstraint?.typeStorage?.possibleConcreteTypes ? : instance.possibleConcreteTypes
2347- val methodInvocationTargets = findLibraryTargets(instance.type, methodSubSignature)
2348- ? : findMethodInvocationTargets(types, methodSubSignature)
2347+
2348+ val allConcreteInvocationTargets = findMethodInvocationTargets(types, methodSubSignature)
2349+ val libraryTargets = findLibraryTargets(instance.type, methodSubSignature)
2350+
2351+ // to choose only "good" targets take only library targets in case they present in all targets,
2352+ // otherwise take all targets
2353+ val methodInvocationTargets = libraryTargets?.takeIf {
2354+ allConcreteInvocationTargets.containsAll(it)
2355+ } ? : allConcreteInvocationTargets
23492356
23502357 return methodInvocationTargets
23512358 .map { (method, implementationClass, possibleTypes) ->
Original file line number Diff line number Diff line change @@ -410,21 +410,16 @@ long closedStreamExample(List<Integer> values) {
410410 }
411411
412412 @ SuppressWarnings ({"ReplaceInefficientStreamCount" , "ConstantConditions" })
413+ // TODO wrong generic type for data field https://github.com/UnitTestBot/UTBotJava/issues/730
413414 long customCollectionStreamExample (CustomCollection <Integer > customCollection ) {
414415 UtMock .assume (customCollection != null && customCollection .data != null );
415416
416- if (customCollection .isEmpty ()) {
417- return customCollection .stream ().count ();
417+ final Stream <Integer > stream = customCollection .stream ();
418418
419- // simplified example, does not generate branch too
420- /*customCollection.removeIf(Objects::isNull);
421- return customCollection.toArray().length;*/
419+ if (customCollection .isEmpty ()) {
420+ return stream .count ();
422421 } else {
423- return customCollection .stream ().count ();
424-
425- // simplified example, does not generate branch too
426- /*customCollection.removeIf(Objects::isNull);
427- return customCollection.toArray().length;*/
422+ return stream .count ();
428423 }
429424 }
430425
You can’t perform that action at this time.
0 commit comments