FoamApplicationInit { public FoamMain init(){ if(application != null) { FoamApiKeys foamApiKeys = getFoamApiKeys(); if (foamApiKeys != null) { foamMain.init(foamApiKeys); foamMain.start(); } else { utils.logIssue("Please add @FoamApiKeys to " + application.getClass().getName(), null); } } return foamMain; } FoamApplicationInit(Application application); FoamMain init();  }
@Test public void testInit() throws Exception { final FoamApiKeys mockfoamApiKeys = mock(FoamApiKeys.class); Application mockApplication = mock(Application.class); FoamApplicationInit foamApplicationInit = new FoamApplicationInit(mockApplication){ @Override FoamApiKeys getFoamApiKeys() { return mockfoamApiKeys; } }; FoamMain mockFoamMain = mock(FoamMain.class); foamApplicationInit.foamMain = mockFoamMain; foamApplicationInit.init(); verify(mockFoamMain).init(eq(mockfoamApiKeys)); verify(mockFoamMain).start(); }
@Test public void testInitNoAnnotation() throws Exception { Application mockApplication = mock(Application.class); Utils mockUtils = UnitTestUtils.mockUtils(); FoamApplicationInit foamApplicationInit = new FoamApplicationInit(mockApplication); FoamMain mockFoamMain = mock(FoamMain.class); foamApplicationInit.foamMain = mockFoamMain; foamApplicationInit.utils = mockUtils; foamApplicationInit.init(); verify(mockFoamMain, never()).init(any(FoamApiKeys.class)); verify(mockFoamMain, never()).start(); verify(mockUtils).logIssue(startsWith("Please add @FoamApiKeys to "), isNull(Throwable.class)); }