As the title says I'm trying to generate unit test classes using JavaPoet Here is the test I want to generate:
@Test
public void TestSettingConstantFieldConstantValue() {
Target mockedTarget = Mockito.mock(Target.class);
sourceToTargetMapper.setConstantFieldConstantValue(mockedTarget);
Mockito.verify(mockedTarget, Mockito.times(1)).setConstantField(Mockito.eq("3"));
}
I'm having a hard time with this part Mockito.mock(Target.class)
This is what I have so far
return CodeBlock.builder()
.addStatement("$T $L = $L.$L ($L)",typesMapperGenerationInput.getTargetClass(),NamingConvention.TARGET_MOCKED_OBJECT, )
typesMapperGenerationInput.getTargetClass()
gives me the Target Object
NamingConvention.TARGET_MOCKED_OBJECT
gives me the mockedTarget
now I wanna pass Mockito
to the next $L
and mock
to the $L
after it
Just passing it as Mockito
won't work..
Any help would be very much appriciated