Skip to content

Spring analyzer crashed on Two animals project #2387

@EgorkaKulikov

Description

@EgorkaKulikov

To Reproduce

Consider TwoAnimals project with excluded Shark class.
Generate tests using AnimalApplication as confihuration class.

Expected behavior

There is only one implementation of Animal, it is Dolphin, so we should avoid mocking interface and use concrete type.

Actual behavior

Actual test is generated with mocks

@Test
@DisplayName("getInjectedName: AnimalGetName -> return animal.getName()")
 public void testGetInjectedName_AnimalGetName() {
    (when(animalMock.getName())).thenReturn(((String) null));

    String actual = animalService.getInjectedName();

    assertNull(actual);
}

Additional context

It seems that Spring analyzer failed.

10:18:55.535 | ERROR | SpringAnalyzerProcess     | RdCategory: SpringApiProviderFacadeImpl | Getting Spring API from org.utbot.spring.provider.SpringBootApiProvider@1bff4e68 failed | java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
	at java.base/java.lang.Class.getMethodsRecursive(Class.java:3543)
	at java.base/java.lang.Class.getMethod0(Class.java:3529)
	at java.base/java.lang.Class.getMethod(Class.java:2225)
	at java.base/java.lang.Class.getEnumConstantsShared(Class.java:3828)
	at java.base/java.lang.Class.enumConstantDirectory(Class.java:3859)
	at java.base/java.lang.Enum.valueOf(Enum.java:267)
	at java.base/sun.reflect.annotation.AnnotationParser.parseEnumValue(AnnotationParser.java:479)
	at java.base/sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:344)
	at java.base/java.lang.reflect.Method.getDefaultValue(Method.java:717)
	at java.base/sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:133)
	at java.base/sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:85)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:262)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:121)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:73)
	at java.base/java.lang.Class.createAnnotationData(Class.java:4068)
	at java.base/java.lang.Class.annotationData(Class.java:4057)
	at java.base/java.lang.Class.createAnnotationData(Class.java:4073)
	at java.base/java.lang.Class.annotationData(Class.java:4057)
	at java.base/java.lang.Class.getAnnotation(Class.java:3940)
	at org.utbot.spring.SpringApiImpl.<init>(SpringApiImpl.kt:31)
	at org.utbot.spring.provider.SpringBootApiProvider.provideAPI(SpringBootApiProvider.kt:18)
	at org.utbot.spring.provider.SpringBootApiProvider.provideAPI(SpringBootApiProvider.kt:8)
	at org.utbot.spring.provider.SpringApiProviderFacadeImpl.useMostSpecificNonFailingApi(SpringApiProviderFacadeImpl.kt:35)
	at org.utbot.spring.analyzer.SpringApplicationAnalyzer.getBeanDefinitions(SpringApplicationAnalyzer.kt:21)
	at org.utbot.spring.process.SpringAnalyzerProcessMainKt$setup$1.invoke(SpringAnalyzerProcessMain.kt:52)
	at org.utbot.spring.process.SpringAnalyzerProcessMainKt$setup$1.invoke(SpringAnalyzerProcessMain.kt:46)

Metadata

Metadata

Assignees

Labels

comp-springIssue is related to Spring projects supportcomp-symbolic-engineIssue is related to the symbolic execution enginectg-bugIssue is a bugspec-regressionRegression

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions