@Test public void executeShouldReturnStatusViewIfAlreadyDone() throws Exception { IImporterManager mockImporterManager = createMockImporterManager(false, true); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterManager(mockImporterManager); Assert.assertEquals(ImportConfirmAction.STATUS, action.execute()); }
@Test public void executeShouldReturnStatusViewIfInProgress() throws Exception { IImporterManager mockImporterManager = createMockImporterManager(true, false); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterManager(mockImporterManager); assertEquals(ImportConfirmAction.STATUS, action.execute()); }
@Test public void executeShouldReturnSuccessViewIfNotAlreadyDone() throws Exception { IImporterManager mockImporterManager = createMockImporterManager(false, false); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterManager(mockImporterManager); assertEquals(ImportConfirmAction.SUCCESS, action.execute()); }
@Test public void getConfigValuesMap() { ImportConfirmAction action = new ImportConfirmAction(); Assert.assertEquals( PropertiesHelper.convertBundleToMap( ResourceBundle.getBundle(Constants.ENVIRONEMENT_BUNDLE_KEY)), action.getConfigValuesMap()); }
@Test public void step2ShouldReturnStep1ViewIfNotAlreadyDone() throws Exception { IImporterManager mockImporterManager = createMockImporterManager(false, false); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterManager(mockImporterManager); Assert.assertEquals(ImportConfirmAction.STEP_BASE_VIEW_NAME + 2, action.step2()); Assert.assertEquals(2, action.step_number); }
@Test public void executeShouldReturnErrorViewIfIsALreadyDoneThrows() throws Exception { String ErrorMessage = "MyMessageToCheck"; IImporterManager mockImporterManager = createImporterManagerThatThrowsWhenIsAlreadyDoneIsCalled(ErrorMessage); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterManager(mockImporterManager); assertEquals(ImportConfirmAction.ERROR, action.execute()); assertEquals("incorect eror message ", ErrorMessage, action.getErrorMessage()); }
@Test public void isRegexpCorrects() { ImporterConfig importerConfig = createMock(ImporterConfig.class); expect(importerConfig.isRegexpCorrects()).andReturn(true); replay(importerConfig); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterConfig(importerConfig); action.isRegexpCorrects(); EasyMock.verify(importerConfig); }
@Test public void isOpenStreetMapDownloadDirectoryAccessible() { ImporterConfig importerConfig = createMock(ImporterConfig.class); expect(importerConfig.isOpenStreetMapDownloadDirectoryAccessible()).andReturn(true); replay(importerConfig); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterConfig(importerConfig); action.isOpenStreetMapDownloadDirectoryAccessible(); EasyMock.verify(importerConfig); }
@Test public void isOpenStreetMapImporterEnabled() { ImporterConfig importerConfig = new ImporterConfig(); Assert.assertTrue(importerConfig.isOpenstreetmapImporterEnabled()); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterConfig(importerConfig); Assert.assertTrue( "isOpenStreetMapImporterEnabled should return the same value as the importerConfig One ", action.isOpenStreetMapImporterEnabled()); importerConfig.setOpenstreetmapImporterEnabled(false); Assert.assertFalse( "isOpenStreetMapImporterEnabled should return the same value as the importerConfig One ", action.isOpenStreetMapImporterEnabled()); }
@Test public void disableGeonamesImporter() { ImporterConfig importerConfig = new ImporterConfig(); Assert.assertTrue(importerConfig.isGeonamesImporterEnabled()); ImportConfirmAction action = new ImportConfirmAction(); action.setImporterConfig(importerConfig); Assert.assertTrue( "isGeonamesImporterEnabled should return the same value as the importerConfig One ", action.isGeonamesImporterEnabled()); Assert.assertEquals(Action.SUCCESS, action.disableGeonamesImporter()); Assert.assertFalse( "isGeonamesImporterEnabled should return the same value as the importerConfig One ", action.isGeonamesImporterEnabled()); }