-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fuzzer ignores generics of class StringMap extends HashMap<String, String>
#2571
Comments
A very similar issue is reproducing on ModelMap is spring framework type extending LinkedHashMap<String, Object> ///region FUZZER: TIMEOUTS for method initCreationForm(org.springframework.samples.petclinic.owner.Owner, org.springframework.ui.ModelMap)
/**
* @utbot.classUnderTest {@link PetController}
* @utbot.methodUnderTest {@link PetController#initCreationForm(Owner, ModelMap)}
*/
@Test
@DisplayName("initCreationForm: owner = mock(), model = collection")
@Timeout(value = 1000L, unit = TimeUnit.MILLISECONDS)
public void testInitCreationForm1() {
Owner ownerMock = mock(Owner.class);
(((Owner) (doNothing()).when(ownerMock))).addPet(any());
ModelMap model = new ModelMap();
Object object = new Object();
Object object1 = new Object();
model.put(object, object1);
Object object2 = new Object();
Object object3 = new Object();
model.put(object2, object3);
Object object4 = new Object();
Object object5 = new Object();
model.put(object4, object5);
Object object6 = new Object();
Object object7 = new Object();
model.put(object6, object7);
/* This execution may take longer than the 1000 ms timeout
and therefore fail due to exceeding the timeout. */
assertTimeoutPreemptively(Duration.ofMillis(1000L), () -> petController.initCreationForm(ownerMock, model));
} And issue - #2595 - is present too. |
Yes, it's the same issue. #2595 only reproduces on UtBot version from #2583 and I hope it will be fixed before #2583 is merged. |
@Markoutte The following test is generated for @Test
public void testProcessCreationFormByFuzzer4() {
Owner ownerMock = mock(Owner.class);
(((Owner) (doNothing()).when(ownerMock))).addPet(any());
Pet petMock = mock(Pet.class);
(when(petMock.getName())).thenReturn("");
BindingResult resultMock = mock(BindingResult.class);
(when(resultMock.hasErrors())).thenReturn(true);
ModelMap model = new ModelMap();
Object object = new Object();
model.put(((Object) "\n\t\r"), object);
String actual = petController.processCreationForm(ownerMock, petMock, resultMock, model);
String expected = "pets/createOrUpdatePetForm";
assertEquals(expected, actual);
}
|
@alisevych Looks like the problem here:
Most likely, it won't compile because of an error with code gen part that try to cast String to Object before it puts the string into map. I've wrote about this problem in PR: #2610. Maybe @EgorkaKulikov or @IlyaMuravjov could take a look at this problem? |
Description
Fuzzer tries to put arbitrary
Objects
intoStringMap
To Reproduce
100%
Expected behavior
There's one passing and one failing test.
Actual behavior
No passing tests are generated, one of the tests fails to compile with the following error: "incompatible types:
Object
cannot be converted toString
stringMap.put(object, object1);
".Visual proofs (screenshots, logs, images)
The text was updated successfully, but these errors were encountered: