I'm coming from objective-c to java and trying to wrap my head around j2objc. I can see that javax.inject.jar is a part of j2objc and I can get the @Inject annotation to compile in my code. but I can't figure out how to get something to actually inject.
Here is a test driving my case:
import org.junit.Test;
import javax.inject.Inject;
import static org.mockito.Mockito.*;
public class PrintsHelloWorld {
@Test
public void happyPath() throws Exception {
HelloWorldPrinter printer = mock(HelloWorldPrinter.class);
new PresenterThingaMajig(printer).doMessageThing();
verify(printer).printHelloWorld();
//What do I do here if I want to see DI using @Inject in action?
}
public class PresenterThingaMajig {
private final HelloWorldPrinter printer;
@Inject
public PresenterThingaMajig(HelloWorldPrinter printer) {
this.printer = printer;
}
public void doMessageThing() {
printer.printHelloWorld();
}
}
public interface HelloWorldPrinter {
void printHelloWorld();
}
public class ConsoleHelloWorldPrinter implements HelloWorldPrinter{
@Override
public void printHelloWorld() {
System.out.println("HELLO WORLD");
}
}
}
I can run and pass this test from intellij, and following the test instructions I can build using j2objc and j2objcc and run it from the command line and it passes... (linking mockito and javax_inject).
What is my next play?
thanks,
jon
--
You received this message because you are subscribed to the Google Groups "j2objc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to j2objc-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import javax.inject.Inject;
To unsubscribe from this group and stop receiving emails from it, send an email to j2objc-discus...@googlegroups.com.