Skip to content
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

Fix to allow spy() with implementations (not interfaces) - IllegalStateException: Injecting null #25

Closed
rbygrave opened this issue Jun 4, 2019 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rbygrave
Copy link
Contributor

rbygrave commented Jun 4, 2019

Where Grinder is an implementation class and not an interface

  @Test
  public void withMockitoSpy_postLoadSetup_expect_spyUsed() {

    try (BeanContext context = new BootContext()
      .withSpy(Pump.class)
      .withSpy(Grinder.class) // HERE
      .load()) {

      ...

      CoffeeMaker coffeeMaker = context.getBean(CoffeeMaker.class);
      coffeeMaker.makeIt();

      ...

      Grinder grinder = context.getBean(Grinder.class);
      verify(grinder).grindBeans(); // throws IllegalStateException
    }
  }
java.lang.IllegalStateException: Injecting null for org.example.coffee.grind.Grinder when creating class org.example.coffee.CoffeeMaker - potential beans to inject: []

	at io.dinject.core.DBuilder.get(DBuilder.java:223)
	at io.dinject.core.DBuilder.get(DBuilder.java:207)
	at org.example.coffee.CoffeeMaker$di.build(CoffeeMaker$di.java:14)
	at org.example.coffee._di$Factory.build_CoffeeMaker(_di$Factory.java:228)
	at org.example.coffee._di$Factory.createContext(_di$Factory.java:92)
	at io.dinject.BootContext.load(BootContext.java:364)
	at org.example.coffee.BootContext_mockitoSpyTest.withMockitoSpy_postLoadSetup_expect_spyUsed(BootContext_mockitoSpyTest.java:64)
	...
@rbygrave rbygrave self-assigned this Jun 4, 2019
@rbygrave rbygrave added the bug Something isn't working label Jun 4, 2019
@rbygrave rbygrave added this to the 1.7 milestone Jun 4, 2019
rbygrave added a commit that referenced this issue Jun 4, 2019
@rbygrave rbygrave closed this as completed Jun 4, 2019
@yaskor
Copy link

yaskor commented Jun 4, 2019

Tested with 1.7-Snapshot. Still failing with "NotAMock"

@rbygrave
Copy link
Contributor Author

rbygrave commented Jun 4, 2019

Are you able to produce a test case?

@yaskor
Copy link

yaskor commented Jun 5, 2019

I will try my best :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants