Constructor Argument mock using JukitoRunner/Mockito in Guice

79 views Asked by At

Hi below is the legacy java code I have and I have to add new test cases to it.

@RunWith(JukitoRunner.class)
public class MyServiceTest {

    @Inject
    private MyService myService;


    public static class TestModule extends JukitoModule {

        @Override
        protected void configureTest() {
            install(new ArchaiusModule() {
                @Override
                protected void configureArchaius() {
                    MapConfig mapConfig = MapConfig.builder()
                                    .put("application.id", APP_ID).build();
                    bindApplicationConfigurationOverride().toInstance(mapConfig);
                }
            });
            bind(Config.class).to(TestConfig.class);
            install(new ABCModule());
        }

    }

MyService implementation MyServiceImpl has below constructor

@Inject
public MyServiceImpl(Config config) {
    this.isEnabled = config.isEnabled();
}

How do I mock Config. I am trying to test isEnabled should return false for one of test cases. New to mockito and guice . I tried @Mock but giving me null.

0

There are 0 answers