I have an injection like
@Inject
@ConfigProperty("BEHOLD_UDSLUS_BEREGNING_MND")
private String maxMonths;
Now i want to mock this in my test class so that the value of "60" can be passed onto the main method. I tried using ReflectionTestUtils.setfield() but somehow its not getting mocked.
List<UdbKonfiguration> udbKonfigList = new ArrayList<UdbKonfiguration>();
UdbKonfiguration udbKonfig = new UdbKonfiguration();
udbKonfig.setKode("BEHOLD_UDSLUS_BEREGNING_MND");
udbKonfig.setValue("60");
udbKonfigList.add(udbKonfig);
try {
ReflectionTestUtils.setField(udbKonfig, "BEHOLD_UDSLUS_BEREGNING_MND", "60", null);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Aucun commentaire:
Enregistrer un commentaire