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 @@ -2346,8 +2346,15 @@ class Traverser(
23462346 // for objects (especially objects with type equals to type parameter of generic)
23472347 // better than engine.
23482348 val types = instanceOfConstraint?.typeStorage?.possibleConcreteTypes ? : instance.possibleConcreteTypes
2349- val methodInvocationTargets = findLibraryTargets(instance.type, methodSubSignature)
2350- ? : findMethodInvocationTargets(types, methodSubSignature)
2349+
2350+ val allPossibleConcreteTypes = typeResolver
2351+ .constructTypeStorage(instance.type, useConcreteType = false )
2352+ .possibleConcreteTypes
2353+
2354+ val methodInvocationTargets = findLibraryTargets(instance.type, methodSubSignature)?.takeIf {
2355+ // we have no specified types, so we can take only library targets (if present) for optimization purposes
2356+ types.size == allPossibleConcreteTypes.size
2357+ } ? : findMethodInvocationTargets(types, methodSubSignature)
23512358
23522359 return methodInvocationTargets
23532360 .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