### Question:
AboutPopup { @PostConstruct public void setup() { view.init(this); if (aboutPopupConfigs.isUnsatisfied()) { throw new RuntimeException("One AboutPopupConfig implementation must be provided"); } if (aboutPopupConfigs.isAmbiguous()) { throw new RuntimeException("Only one AboutPopupConfig implementation must be provided"); } final AboutPopupConfig aboutPopupConfig = aboutPopupConfigs.get(); view.setProductName(aboutPopupConfig.productName()); view.setProductVersion(aboutPopupConfig.productVersion()); view.setProductLicense(aboutPopupConfig.productLicense()); view.setProductImageUrl(aboutPopupConfig.productImageUrl()); final String backgroundImageUrl = aboutPopupConfig.backgroundImageUrl(); if (backgroundImageUrl != null && !backgroundImageUrl.isEmpty()) { view.setBackgroundImageUrl(backgroundImageUrl); } } @Inject  AboutPopup(final View view,
                      final ManagedInstance<AboutPopupConfig> aboutPopupConfigs); @PostConstruct void setup(); void show();  }### Answer:
@Test public void setupWithOneCompleteConfigTest() { doReturn(false).when(aboutPopupConfigs).isUnsatisfied(); doReturn(false).when(aboutPopupConfigs).isAmbiguous(); doReturn(config).when(aboutPopupConfigs).get(); aboutPopup.setup(); verify(view).init(aboutPopup); verify(view).setProductName(config.productName()); verify(view).setProductVersion(config.productVersion()); verify(view).setProductLicense(config.productLicense()); verify(view).setProductImageUrl(config.productImageUrl()); verify(view).setBackgroundImageUrl(config.backgroundImageUrl()); }
@Test public void setupWithOneConfigWithoutBackgroundImageTest() { doReturn(false).when(aboutPopupConfigs).isUnsatisfied(); doReturn(false).when(aboutPopupConfigs).isAmbiguous(); doReturn(new AboutPopupConfigMock("")).when(aboutPopupConfigs).get(); aboutPopup.setup(); verify(view).init(aboutPopup); verify(view).setProductName(config.productName()); verify(view).setProductVersion(config.productVersion()); verify(view).setProductLicense(config.productLicense()); verify(view).setProductImageUrl(config.productImageUrl()); verify(view, never()).setBackgroundImageUrl(anyString()); }
@Test(expected = RuntimeException.class) public void setupWithNoConfigTest() { doReturn(true).when(aboutPopupConfigs).isUnsatisfied(); doReturn(false).when(aboutPopupConfigs).isAmbiguous(); aboutPopup.setup(); }
@Test(expected = RuntimeException.class) public void setupWithSeveralConfigsTest() { doReturn(false).when(aboutPopupConfigs).isUnsatisfied(); doReturn(true).when(aboutPopupConfigs).isAmbiguous(); aboutPopup.setup(); }