agresch commented on code in PR #3479: URL: https://github.com/apache/storm/pull/3479#discussion_r878457125
########## external/storm-jdbc/src/test/java/org/apache/storm/jdbc/common/JdbcClientTest.java: ########## @@ -88,24 +86,19 @@ public void testInsertConnectionError() { this.client = new JdbcClient(connectionProvider, 60); List<Column> row = createRow(1, "frank"); - List<List<Column>> rows = new ArrayList<List<Column>>(); + List<List<Column>> rows = new ArrayList<>(); rows.add(row); String query = "insert into user_details values(?,?,?)"; - thrown.expect(MultipleFailureException.class); - client.executeInsertQuery(query, rows); + assertThrows(RuntimeException.class, () -> client.executeInsertQuery(query, rows)); Review Comment: Why isn't this MultipleFailureException? ########## external/storm-jdbc/src/test/java/org/apache/storm/jdbc/common/JdbcClientTest.java: ########## @@ -88,24 +86,19 @@ public void testInsertConnectionError() { this.client = new JdbcClient(connectionProvider, 60); List<Column> row = createRow(1, "frank"); - List<List<Column>> rows = new ArrayList<List<Column>>(); + List<List<Column>> rows = new ArrayList<>(); rows.add(row); String query = "insert into user_details values(?,?,?)"; - thrown.expect(MultipleFailureException.class); - client.executeInsertQuery(query, rows); + assertThrows(RuntimeException.class, () -> client.executeInsertQuery(query, rows)); + assertThrows(RuntimeException.class, () -> client.executeSql("drop table " + tableName)); Review Comment: Is this supposed to throw? I'm not sure where this mapped to originally. ########## storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java: ########## @@ -63,51 +63,55 @@ public class DependencyUploaderTest { private DependencyUploader sut; private ClientBlobStore mockBlobStore; - @Before + @BeforeEach public void setUp() throws Exception { sut = new DependencyUploader(); mockBlobStore = mock(ClientBlobStore.class); sut.setBlobStore(mockBlobStore); doNothing().when(mockBlobStore).shutdown(); } - @After + @AfterEach public void tearDown() throws Exception { sut.shutdown(); } - @Test(expected = FileNotAvailableException.class) - public void uploadFilesWhichOneOfThemIsNotFoundInLocal() throws Exception { - File mockFile = mock(File.class); - when(mockFile.isFile()).thenReturn(true); - when(mockFile.exists()).thenReturn(true); - - File mockFile2 = mock(File.class); - when(mockFile.isFile()).thenReturn(true); - when(mockFile.exists()).thenReturn(false); - - List<File> dependencies = new ArrayList<>(); - dependencies.add(mockFile); - dependencies.add(mockFile2); - - sut.uploadFiles(dependencies, false); - fail("Should throw FileNotAvailableException"); + @Test + public void uploadFilesWhichOneOfThemIsNotFoundInLocal() { + assertThrows(FileNotAvailableException.class, () -> { + File mockFile = mock(File.class); + when(mockFile.isFile()).thenReturn(true); + when(mockFile.exists()).thenReturn(true); + + File mockFile2 = mock(File.class); + when(mockFile.isFile()).thenReturn(true); + when(mockFile.exists()).thenReturn(false); + + List<File> dependencies = new ArrayList<>(); + dependencies.add(mockFile); + dependencies.add(mockFile2); + + sut.uploadFiles(dependencies, false); + }); + // fail("Should throw FileNotAvailableException"); } - @Test(expected = FileNotAvailableException.class) - public void uploadFilesWhichOneOfThemIsNotFile() throws Exception { - File mockFile = mock(File.class); - when(mockFile.isFile()).thenReturn(true); - when(mockFile.exists()).thenReturn(true); + @Test + public void uploadFilesWhichOneOfThemIsNotFile() { + assertThrows(FileNotAvailableException.class, () -> { + File mockFile = mock(File.class); + when(mockFile.isFile()).thenReturn(true); + when(mockFile.exists()).thenReturn(true); - File mockFile2 = mock(File.class); - when(mockFile.isFile()).thenReturn(false); - when(mockFile.exists()).thenReturn(true); + File mockFile2 = mock(File.class); + when(mockFile.isFile()).thenReturn(false); + when(mockFile.exists()).thenReturn(true); - List<File> dependencies = Lists.newArrayList(mockFile, mockFile2); + List<File> dependencies = Lists.newArrayList(mockFile, mockFile2); - sut.uploadFiles(dependencies, false); - fail("Should throw FileNotAvailableException"); + sut.uploadFiles(dependencies, false); + }); + // fail("Should throw FileNotAvailableException"); Review Comment: remove in all locations this file. ########## external/storm-hdfs-blobstore/src/test/java/org/apache/storm/hdfs/blobstore/BlobStoreTest.java: ########## @@ -62,10 +61,9 @@ public class BlobStoreTest { public static final MiniDFSClusterExtension DFS_CLUSTER_EXTENSION = new MiniDFSClusterExtension(); private static final Logger LOG = LoggerFactory.getLogger(BlobStoreTest.class); - URI base; private static final Map<String, Object> CONF = new HashMap<>(); public static final int READ = 0x01; - public static final int WRITE = 0x02; + // public static final int WRITE = 0x02; Review Comment: remove this ########## storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java: ########## @@ -63,51 +63,55 @@ public class DependencyUploaderTest { private DependencyUploader sut; private ClientBlobStore mockBlobStore; - @Before + @BeforeEach public void setUp() throws Exception { sut = new DependencyUploader(); mockBlobStore = mock(ClientBlobStore.class); sut.setBlobStore(mockBlobStore); doNothing().when(mockBlobStore).shutdown(); } - @After + @AfterEach public void tearDown() throws Exception { sut.shutdown(); } - @Test(expected = FileNotAvailableException.class) - public void uploadFilesWhichOneOfThemIsNotFoundInLocal() throws Exception { - File mockFile = mock(File.class); - when(mockFile.isFile()).thenReturn(true); - when(mockFile.exists()).thenReturn(true); - - File mockFile2 = mock(File.class); - when(mockFile.isFile()).thenReturn(true); - when(mockFile.exists()).thenReturn(false); - - List<File> dependencies = new ArrayList<>(); - dependencies.add(mockFile); - dependencies.add(mockFile2); - - sut.uploadFiles(dependencies, false); - fail("Should throw FileNotAvailableException"); + @Test + public void uploadFilesWhichOneOfThemIsNotFoundInLocal() { + assertThrows(FileNotAvailableException.class, () -> { + File mockFile = mock(File.class); + when(mockFile.isFile()).thenReturn(true); + when(mockFile.exists()).thenReturn(true); + + File mockFile2 = mock(File.class); + when(mockFile.isFile()).thenReturn(true); + when(mockFile.exists()).thenReturn(false); + + List<File> dependencies = new ArrayList<>(); + dependencies.add(mockFile); + dependencies.add(mockFile2); + + sut.uploadFiles(dependencies, false); + }); + // fail("Should throw FileNotAvailableException"); Review Comment: remove ########## storm-client/test/jvm/org/apache/storm/TestConfigValidate.java: ########## @@ -822,20 +805,19 @@ public void TestImpersonationAclUserEntryValidator() throws InvocationTargetExce for (Object value : passCases) { config.put(TestConfig.TEST_MAP_CONFIG_6, value); - ConfigValidation.validateFields(config, Arrays.asList(TestConfig.class)); + ConfigValidation.validateFields(config, Collections.singletonList(TestConfig.class)); } - Map<String, Map<String, List<String>>> failCase1 = new HashMap<String, Map<String, List<String>>>(); - Map<String, List<String>> failCase1_hostsAndGroups = new HashMap<String, List<String>>(); - String[] failhosts = { "host.1", "host.2", "host.3" }; + Map<String, Map<String, List<String>>> failCase1 = new HashMap<>(); + Map<String, List<String>> failCase1_hostsAndGroups = new HashMap<>(); failCase1_hostsAndGroups.put("hosts", Arrays.asList(hosts)); failCase1.put("jerry", failCase1_hostsAndGroups); - Map<String, Map<String, List<String>>> failCase2 = new HashMap<String, Map<String, List<String>>>(); - Map<String, List<String>> failCase2_hostsAndGroups = new HashMap<String, List<String>>(); + Map<String, Map<String, List<String>>> failCase2 = new HashMap<>(); + Map<String, List<String>> failCase2_hostsAndGroups = new HashMap<>(); String[] failgroups = { "group.1", "group.2", "group.3" }; - failCase2_hostsAndGroups.put("groups", Arrays.asList(groups)); + failCase2_hostsAndGroups.put("groups", Arrays.asList(groups)); // should this be failGroups ? Review Comment: remove comment (or address) ########## storm-server/src/test/java/org/apache/storm/daemon/supervisor/SlotTest.java: ########## @@ -147,7 +144,7 @@ public void testEmptyToEmpty() throws Exception { @Test public void testLaunchContainerFromEmpty() throws Exception { - try (SimulatedTime t = new SimulatedTime(1010)) { + try (SimulatedTime ignored = new SimulatedTime(1010)) { Review Comment: just curious why the rename to ignored? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@storm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org