diff --git a/data/data-api/src/test/java/org/orbisgis/data/api/dataset/IJdbcTableTest.java b/data/data-api/src/test/java/org/orbisgis/data/api/dataset/IJdbcTableTest.java index ffe2cecb..09042c00 100644 --- a/data/data-api/src/test/java/org/orbisgis/data/api/dataset/IJdbcTableTest.java +++ b/data/data-api/src/test/java/org/orbisgis/data/api/dataset/IJdbcTableTest.java @@ -105,7 +105,7 @@ private static class DummyTableLocation implements ITableLocation { /** * Fake data location. */ - private String location; + private final String location; /** diff --git a/data/data-api/src/test/java/org/orbisgis/data/api/datasource/IJdbcDataSourceTest.java b/data/data-api/src/test/java/org/orbisgis/data/api/datasource/IJdbcDataSourceTest.java index bd0b8248..b3080918 100644 --- a/data/data-api/src/test/java/org/orbisgis/data/api/datasource/IJdbcDataSourceTest.java +++ b/data/data-api/src/test/java/org/orbisgis/data/api/datasource/IJdbcDataSourceTest.java @@ -152,8 +152,8 @@ private class DummyException extends Exception { * Simple implementation of the {@link IJdbcDataSource} interface. */ private class DummyDataSource implements IJdbcDataSource { - private Object prop1; - private Object prop2; + private final Object prop1; + private final Object prop2; private boolean streamScript = false; private boolean fileScript = false; diff --git a/data/dataframe/src/test/java/org/orbisgis/data/dataframe/DataFrameTest.java b/data/dataframe/src/test/java/org/orbisgis/data/dataframe/DataFrameTest.java index e7652393..f0497f77 100644 --- a/data/dataframe/src/test/java/org/orbisgis/data/dataframe/DataFrameTest.java +++ b/data/dataframe/src/test/java/org/orbisgis/data/dataframe/DataFrameTest.java @@ -220,8 +220,8 @@ void getTypeTest(){ assertEquals((byte)3, dataFrame.getObject(4, Byte.class)); assertEquals((short)3, dataFrame.getObject(5, short.class)); assertEquals((short)3, dataFrame.getObject(5, Short.class)); - assertEquals(3l, dataFrame.getObject(6, long.class)); - assertEquals(3l, dataFrame.getObject(6, Long.class)); + assertEquals(3L, dataFrame.getObject(6, long.class)); + assertEquals(3L, dataFrame.getObject(6, Long.class)); assertEquals(3.5f, dataFrame.getObject(7, float.class)); assertEquals(3.5f, dataFrame.getObject(7, Float.class)); assertEquals(3d, dataFrame.getObject(8, double.class)); @@ -244,8 +244,8 @@ void getTypeTest(){ assertEquals(4, dataFrame.getObject("COL5", Integer.class)); assertEquals(4, dataFrame.getObject("COL6", int.class)); assertEquals(4, dataFrame.getObject("COL6", Integer.class)); - assertEquals(4l, dataFrame.getObject("COL7", long.class)); - assertEquals(4l, dataFrame.getObject("COL7", Long.class)); + assertEquals(4L, dataFrame.getObject("COL7", long.class)); + assertEquals(4L, dataFrame.getObject("COL7", Long.class)); assertEquals(4.5f, dataFrame.getObject("COL8", float.class)); assertEquals(4.5f, dataFrame.getObject("COL8", Float.class)); assertEquals(4d, dataFrame.getObject("COL9", double.class)); @@ -588,7 +588,7 @@ void testRandomForestNominalValuesInResult() { // Dataset used BaseVector[] bv = new BaseVector[]{ IntVector.of("LCZ", new int[]{105, 107, 106, 105, 105, 106, 107, 106, 106, 107, 107, 107, 107}), - StringVector.of("TYPE", new String[]{"grass", "corn", "corn", "grass", "corn", "grass", "forest", "grass", "grass", "corn", "corn", "corn", "corn"}), + StringVector.of("TYPE", "grass", "corn", "corn", "grass", "corn", "grass", "forest", "grass", "grass", "corn", "corn", "corn", "corn"), IntVector.of("TEMPERATURE", new int[]{12, 12, 18, 12, 16, 12, 12, 12, 16, 16, 2, 16, 18}), IntVector.of("WIND", new int[]{20, 30, 20, 30, 20, 20, 20, 20, 20, 20, 20, 50, 40}), }; diff --git a/data/h2gis/src/test/java/org/orbisgis/data/H2GISDataSourceTest.java b/data/h2gis/src/test/java/org/orbisgis/data/H2GISDataSourceTest.java index ffcb602e..0a91ba6a 100644 --- a/data/h2gis/src/test/java/org/orbisgis/data/H2GISDataSourceTest.java +++ b/data/h2gis/src/test/java/org/orbisgis/data/H2GISDataSourceTest.java @@ -88,7 +88,7 @@ class H2GISDataSourceTest { * @throws SQLException Sql exception. */ @BeforeEach - void init() throws SQLException, Exception { + void init() throws Exception { h2gis = H2GIS.open(DB_NAME); h2gis.execute("DROP TABLE IF EXISTS test_h2gis"); h2gis.execute("CREATE TABLE test_h2gis(id int, the_geom GEOMETRY, text varchar)"); @@ -266,7 +266,7 @@ public Object call(Object arguments) { */ @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - void testExecuteMethod1() throws URISyntaxException, SQLException, Exception { + void testExecuteMethod1() throws Exception { Map map = new HashMap<>(); map.put("intArg", "51"); URL url = this.getClass().getResource("simpleWithArgs.sql"); @@ -303,7 +303,7 @@ void testExecuteMethod1() throws URISyntaxException, SQLException, Exception { */ @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - void testExecuteMethod2() throws SQLException, Exception { + void testExecuteMethod2() throws Exception { Map map = new HashMap<>(); map.put("intArg", "51"); @@ -341,7 +341,7 @@ void testMetaClassMethods() { */ @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - void testSave() throws SQLException, MalformedURLException, Exception { + void testSave() throws Exception { h2gis.execute("DROP TABLE IF EXISTS load"); postgis.execute("DROP TABLE IF EXISTS load"); @@ -382,7 +382,7 @@ void testSave() throws SQLException, MalformedURLException, Exception { */ @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - void testLink() throws SQLException, URISyntaxException, MalformedURLException, Exception { + void testLink() throws Exception { URL url = this.getClass().getResource("linkTable.dbf"); URI uri = url.toURI(); File file = new File(uri); @@ -503,7 +503,7 @@ void testLink() throws SQLException, URISyntaxException, MalformedURLException, */ @Disabled @Test - void loadFromDB() throws SQLException, Exception { + void loadFromDB() throws Exception { String tableNameDS1 = "test_h2gis"; String tableNameDS2 = "test_postgis"; @@ -547,7 +547,7 @@ void loadFromDB() throws SQLException, Exception { */ @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - void testLoadPath() throws SQLException, URISyntaxException, Exception { + void testLoadPath() throws Exception { URL url = this.getClass().getResource("loadTable.dbf"); URI uri = url.toURI(); File file = new File(uri); @@ -808,12 +808,12 @@ void testHasTable() throws Exception { @EnabledIfSystemProperty(named = "test.postgis", matches = "true") void testGetDataSet() throws Exception { Object dataset = h2gis.getDataSet("TEST_H2GIS"); - assertTrue(dataset instanceof ISpatialTable); + assertInstanceOf(ISpatialTable.class, dataset); dataset = h2gis.getDataSet("GEOMETRY_COLUMNS"); assertNotNull(dataset); dataset = postgis.getDataSet("test_postgis"); - assertTrue(dataset instanceof ISpatialTable); + assertInstanceOf(ISpatialTable.class, dataset); dataset = postgis.getDataSet("geometry_columns"); assertNotNull(dataset); } @@ -836,7 +836,7 @@ void testResultSetBuilder() throws Exception { .maxFieldSize(FIELD_SIZE).getTable("TEST_H2GIS"); assertNotNull(table); assertArrayEquals(new int[]{3, 3}, table.getSize()); - assertTrue(table instanceof H2gisSpatialTable); + assertInstanceOf(H2gisSpatialTable.class, table); IResultSetProperties rsp = ((H2gisSpatialTable)table).getResultSetProperties(); assertEquals(ResultSet.TYPE_FORWARD_ONLY, rsp.getType()); assertEquals(ResultSet.CONCUR_READ_ONLY, rsp.getConcurrency()); @@ -854,7 +854,7 @@ void testResultSetBuilder() throws Exception { .maxFieldSize(FIELD_SIZE).getTable("test_postgis"); assertNotNull(table); assertArrayEquals(new int[]{3, 3}, table.getSize()); - assertTrue(table instanceof PostgisSpatialTable); + assertInstanceOf(PostgisSpatialTable.class, table); rsp = ((PostgisSpatialTable)table).getResultSetProperties(); assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, rsp.getType()); assertEquals(ResultSet.CONCUR_READ_ONLY, rsp.getConcurrency()); diff --git a/data/h2gis/src/test/java/org/orbisgis/data/H2GISTests.java b/data/h2gis/src/test/java/org/orbisgis/data/H2GISTests.java index 76391869..e27b6ed6 100644 --- a/data/h2gis/src/test/java/org/orbisgis/data/H2GISTests.java +++ b/data/h2gis/src/test/java/org/orbisgis/data/H2GISTests.java @@ -78,7 +78,7 @@ public void openH2GIS() throws Exception { } @Test - public void testColumnsType() throws SQLException, Exception { + public void testColumnsType() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS"); H2GIS h2GIS = H2GIS.open(map); @@ -89,9 +89,9 @@ public void testColumnsType() throws SQLException, Exception { Map columnTypes = h2GIS.getColumnNamesTypes("types"); assertTrue(columnTypes.containsKey("COLINT")); - assertTrue(columnTypes.get("COLINT")=="INTEGER"); + assertSame("INTEGER", columnTypes.get("COLINT")); assertTrue(columnTypes.containsKey("COLREAL")); - assertTrue(columnTypes.get("COLREAL")=="REAL"); + assertSame("REAL", columnTypes.get("COLREAL")); } @@ -105,7 +105,7 @@ public void loadH2GIS() throws Exception { @Test - public void queryH2GIS() throws SQLException, Exception { + public void queryH2GIS() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS2"); H2GIS h2GIS = H2GIS.open(map); @@ -125,7 +125,7 @@ public Object call(Object argument) { } @Test - public void querySpatialTable() throws SQLException, Exception { + public void querySpatialTable() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS2"); H2GIS h2GIS = H2GIS.open(map); @@ -153,7 +153,7 @@ public Object call(Object argument) { } @Test - public void queryTableNames() throws SQLException, Exception { + public void queryTableNames() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS"); H2GIS h2GIS = H2GIS.open(map); @@ -167,7 +167,7 @@ public void queryTableNames() throws SQLException, Exception { } @Test - public void updateSpatialTable() throws SQLException, Exception { + public void updateSpatialTable() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS"); H2GIS h2GIS = H2GIS.open(map); @@ -208,7 +208,7 @@ public Object call(Object argument) { } @Test - public void request() throws SQLException, Exception { + public void request() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS2"); H2GIS h2GIS = H2GIS.open(map); @@ -293,7 +293,7 @@ public Object call(Object argument) { } @Test - public void hasTable() throws SQLException, Exception { + public void hasTable() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS"); H2GIS h2GIS = H2GIS.open(map); @@ -308,7 +308,7 @@ public void hasTable() throws SQLException, Exception { } @Test - void testGetTableOnEmptyTable() throws SQLException, Exception { + void testGetTableOnEmptyTable() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/loadH2GIS"); H2GIS h2GIS = H2GIS.open(map); @@ -374,7 +374,7 @@ void addNetworkFunctionsTest() throws Exception { } @Test - void testExtent() throws SQLException, Exception { + void testExtent() throws Exception { H2GIS h2GIS = H2GIS.open("./target/orbisgis"); h2GIS.execute("DROP TABLE IF EXISTS forests;\n" + " CREATE TABLE forests ( fid INTEGER NOT NULL PRIMARY KEY, name CHARACTER VARYING(64),\n" + @@ -394,7 +394,7 @@ void testExtent() throws SQLException, Exception { } @Test - void testExtentWithFilter() throws SQLException, Exception { + void testExtentWithFilter() throws Exception { H2GIS h2GIS = H2GIS.open("./target/orbisgis"); h2GIS.execute("DROP TABLE IF EXISTS forests;\n" + " CREATE TABLE forests ( fid INTEGER NOT NULL PRIMARY KEY, name CHARACTER VARYING(64),\n" + @@ -414,7 +414,7 @@ void testExtentWithFilter() throws SQLException, Exception { } @Test - public void getTableSelect() throws SQLException, Exception { + public void getTableSelect() throws Exception { Map map = new HashMap<>(); map.put(H2GISDBFactory.JDBC_DATABASE_NAME, "./target/selectTable"); H2GIS h2GIS = H2GIS.open(map); diff --git a/data/h2gis/src/test/java/org/orbisgis/data/H2gisSpatialTableTest.java b/data/h2gis/src/test/java/org/orbisgis/data/H2gisSpatialTableTest.java index fb4ad2a9..42b0e4ac 100644 --- a/data/h2gis/src/test/java/org/orbisgis/data/H2gisSpatialTableTest.java +++ b/data/h2gis/src/test/java/org/orbisgis/data/H2gisSpatialTableTest.java @@ -108,15 +108,15 @@ public void testAsType() throws Exception { fail(e); } ISpatialTable table = h2gis.getSpatialTable("name"); - assertTrue(table.asType(ISpatialTable.class) instanceof ISpatialTable); - assertTrue(table.asType(ITable.class) instanceof ITable); - assertTrue(table.asType(H2gisSpatialTable.class) instanceof H2gisSpatialTable); - assertTrue(table.asType(H2gisTable.class) instanceof H2gisTable); + assertInstanceOf(ISpatialTable.class, table.asType(ISpatialTable.class)); + assertInstanceOf(ITable.class, table.asType(ITable.class)); + assertInstanceOf(H2gisSpatialTable.class, table.asType(H2gisSpatialTable.class)); + assertInstanceOf(H2gisTable.class, table.asType(H2gisTable.class)); assertNull(table.asType(String.class)); } @Test - void testReproject() throws SQLException, Exception { + void testReproject() throws Exception { new File("target/reprojected_table.shp").delete(); H2GIS dataSource = H2GIS.open("./target/test"); dataSource.execute(" DROP TABLE IF EXISTS orbisgis;" + @@ -138,7 +138,7 @@ void testReproject() throws SQLException, Exception { IJdbcTable reprojectedTable = dataSource.getTable(dataSource.load("target/reprojected_table.shp", true)); assertNotNull(reprojectedTable); assertEquals(2, reprojectedTable.getRowCount()); - assertTrue(reprojectedTable instanceof IJdbcSpatialTable); + assertInstanceOf(IJdbcSpatialTable.class, reprojectedTable); IJdbcSpatialTable spatialReprojectedTable = (IJdbcSpatialTable) reprojectedTable; assertEquals(2154, spatialReprojectedTable.getSrid()); @@ -150,7 +150,7 @@ void testReproject() throws SQLException, Exception { } @Test - void testSaveQueryInFile() throws SQLException, Exception { + void testSaveQueryInFile() throws Exception { new File("target/query_table.shp").delete(); H2GIS dataSource = H2GIS.open("./target/test"); dataSource.execute(" DROP TABLE IF EXISTS orbisgis, query_table;" + @@ -166,7 +166,7 @@ void testSaveQueryInFile() throws SQLException, Exception { IJdbcTable queryTable = dataSource.getTable(dataSource.load("target/query_table.shp")); assertNotNull(queryTable); assertEquals(2, queryTable.getRowCount()); - assertTrue(queryTable instanceof IJdbcSpatialTable); + assertInstanceOf(IJdbcSpatialTable.class, queryTable); IJdbcSpatialTable spatialReprojectedTable = (IJdbcSpatialTable) queryTable; assertEquals(4326, spatialReprojectedTable.getSrid()); @@ -174,7 +174,7 @@ void testSaveQueryInFile() throws SQLException, Exception { IJdbcSpatialTable spLoaded = dataSource.getSpatialTable("QUERY_TABLE"); assertEquals(2, spLoaded.getRowCount()); assertEquals(4326, spLoaded.getSrid()); - assertTrue(spLoaded.getFirstRow().get(1) instanceof Point); + assertInstanceOf(Point.class, spLoaded.getFirstRow().get(1)); } /** * Test the {@link JdbcSpatialTable#isSpatial()} method. diff --git a/data/h2gis/src/test/java/org/orbisgis/data/H2gisTableTest.java b/data/h2gis/src/test/java/org/orbisgis/data/H2gisTableTest.java index 778fda7d..fe9f39a3 100644 --- a/data/h2gis/src/test/java/org/orbisgis/data/H2gisTableTest.java +++ b/data/h2gis/src/test/java/org/orbisgis/data/H2gisTableTest.java @@ -324,7 +324,7 @@ void firstRowTest() throws Exception { assertEquals("Simple points", map.get(COL_MEANING)); map = getTempTable().firstRow(); - assertTrue(!map.isEmpty()); + assertFalse(map.isEmpty()); map = getEmptyTable().firstRow(); assertTrue(map.isEmpty()); @@ -335,7 +335,7 @@ void firstRowTest() throws Exception { * Test the {@link IJdbcTable#getLocation()} method. */ @Test - public void testGetLocation() throws SQLException, Exception { + public void testGetLocation() throws Exception { assertEquals("catalog.schema.table", new PostgisTable( new TableLocation("catalog", "schema", "table"), "not a request", dataSource.getConnection().createStatement(), null, dataSource).getLocation()); @@ -356,7 +356,7 @@ public void testGetLocation() throws SQLException, Exception { * Test the {@link JdbcTable#getMetaData()} constructor. */ @Test - void testGetMetadata() throws SQLException, Exception { + void testGetMetadata() throws Exception { assertNotNull(getTable().getMetaData()); assertNotNull(getLinkedTable().getMetaData()); assertNotNull(getTempTable().getMetaData()); @@ -679,7 +679,7 @@ void testGetTable() throws Exception { @Test public void testAsType() throws Exception { assertNotNull(getTable().asType(ITable.class)); - assertTrue(getTable().asType(ITable.class) instanceof ITable); + assertInstanceOf(ITable.class, getTable().asType(ITable.class)); assertNotNull(getTable().asType(ISpatialTable.class)); assertEquals("+--------------------+\n" + "| ORBISGIS_TABLE |\n" + diff --git a/data/postgis/src/main/java/org/orbisgis/data/POSTGIS.java b/data/postgis/src/main/java/org/orbisgis/data/POSTGIS.java index f3686f35..25f099e8 100644 --- a/data/postgis/src/main/java/org/orbisgis/data/POSTGIS.java +++ b/data/postgis/src/main/java/org/orbisgis/data/POSTGIS.java @@ -488,7 +488,7 @@ public void dropColumn(String tableName, String... columnName) { return; } try { - StringBuilder sb = new StringBuilder("ALTER TABLE IF EXISTS " + TableLocation.parse(tableName, DBTypes.POSTGIS).toString()); + StringBuilder sb = new StringBuilder("ALTER TABLE IF EXISTS " + TableLocation.parse(tableName, DBTypes.POSTGIS)); int count = columnName.length; for (int i = 0; i < count; i++) { String col = columnName[i]; diff --git a/data/postgis/src/test/groovy/org/orbisgis/data/GroovyPostGISTest.groovy b/data/postgis/src/test/groovy/org/orbisgis/data/GroovyPostGISTest.groovy index 70944d19..203b793c 100644 --- a/data/postgis/src/test/groovy/org/orbisgis/data/GroovyPostGISTest.groovy +++ b/data/postgis/src/test/groovy/org/orbisgis/data/GroovyPostGISTest.groovy @@ -507,31 +507,31 @@ class GroovyPostGISTest { @EnabledIfSystemProperty(named = "test.postgis", matches = "true") void testDataSourceMethods() throws SQLException { postGIS.execute("DROP TABLE IF EXISTS geodata; CREATE TABLE geodata (ID INT,LAND VARCHAR, THE_GEOM GEOMETRY); " + - "INSERT INTO geodata VALUES (1,'grass', 'POINT(0 0)'::GEOMETRY);"); - assertFalse(postGIS.isEmpty("geodata")); + "INSERT INTO geodata VALUES (1,'grass', 'POINT(0 0)'::GEOMETRY);") + assertFalse(postGIS.isEmpty("geodata")) assertEquals(1, postGIS.getRowCount("geodata")) - assertTrue(postGIS.createIndex("geodata", "id")); - assertTrue(postGIS.isIndexed("geodata", "id")); - postGIS.dropIndex("geodata", "id"); - assertFalse(postGIS.isIndexed("geodata", "id")); + assertTrue(postGIS.createIndex("geodata", "id")) + assertTrue(postGIS.isIndexed("geodata", "id")) + postGIS.dropIndex("geodata", "id") + assertFalse(postGIS.isIndexed("geodata", "id")) - assertTrue(postGIS.createSpatialIndex("geodata", "the_geom")); - assertTrue(postGIS.isSpatialIndexed("geodata", "the_geom")); - postGIS.dropIndex("geodata", "the_geom"); - assertFalse(postGIS.isSpatialIndexed("geodata", "the_geom")); + assertTrue(postGIS.createSpatialIndex("geodata", "the_geom")) + assertTrue(postGIS.isSpatialIndexed("geodata", "the_geom")) + postGIS.dropIndex("geodata", "the_geom") + assertFalse(postGIS.isSpatialIndexed("geodata", "the_geom")) - assertTrue(postGIS.createSpatialIndex("geodata")); - assertTrue(postGIS.isSpatialIndexed("geodata")); + assertTrue(postGIS.createSpatialIndex("geodata")) + assertTrue(postGIS.isSpatialIndexed("geodata")) - assertEquals(postGIS.firstRow("select 'POINT(0 0)'::GEOMETRY AS the_geom").get("THE_GEOM"), postGIS.getExtent("geodata")); + assertEquals(postGIS.firstRow("select 'POINT(0 0)'::GEOMETRY AS the_geom").get("THE_GEOM"), postGIS.getExtent("geodata")) - postGIS.dropColumn("geodata", "id", "land", "type"); - assertEquals(1,postGIS.getColumnNames("geodata").size()); + postGIS.dropColumn("geodata", "id", "land", "type") + assertEquals(1,postGIS.getColumnNames("geodata").size()) - postGIS.dropTable("geodata"); - assertFalse(postGIS.hasTable("geodata")); + postGIS.dropTable("geodata") + assertFalse(postGIS.hasTable("geodata")) postGIS.dropTable("", "") postGIS.dropTable([]) diff --git a/data/postgis/src/test/java/org/orbisgis/data/PostGISSpatialTableTest.java b/data/postgis/src/test/java/org/orbisgis/data/PostGISSpatialTableTest.java index f506260d..d6a1eb47 100644 --- a/data/postgis/src/test/java/org/orbisgis/data/PostGISSpatialTableTest.java +++ b/data/postgis/src/test/java/org/orbisgis/data/PostGISSpatialTableTest.java @@ -125,16 +125,16 @@ public void testAsType() throws Exception { fail(e); } ISpatialTable table = postGIS.getSpatialTable("name"); - assertTrue(table.asType(ISpatialTable.class) instanceof ISpatialTable); - assertTrue(table.asType(ITable.class) instanceof ITable); - assertTrue(table.asType(PostgisSpatialTable.class) instanceof PostgisSpatialTable); - assertTrue(table.asType(PostgisTable.class) instanceof PostgisTable); + assertInstanceOf(ISpatialTable.class, table.asType(ISpatialTable.class)); + assertInstanceOf(ITable.class, table.asType(ITable.class)); + assertInstanceOf(PostgisSpatialTable.class, table.asType(PostgisSpatialTable.class)); + assertInstanceOf(PostgisTable.class, table.asType(PostgisTable.class)); assertThrows(Exception.class, ()->table.asType(String.class)); } @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - void testReproject() throws SQLException, Exception { + void testReproject() throws Exception { postGIS.execute(" DROP TABLE IF EXISTS orbisgis;" + "CREATE TABLE orbisgis (id int, the_geom geometry(point, 4326));" + "INSERT INTO orbisgis VALUES (1, 'SRID=4326;POINT(10 10)'::GEOMETRY), " + @@ -153,7 +153,7 @@ void testReproject() throws SQLException, Exception { IJdbcTable reprojectedTable = postGIS.getTable(postGIS.load("target/reprojected_table.shp", true)); assertNotNull(reprojectedTable); assertEquals(2, reprojectedTable.getRowCount()); - assertTrue(reprojectedTable instanceof IJdbcSpatialTable); + assertInstanceOf(IJdbcSpatialTable.class, reprojectedTable); IJdbcSpatialTable spatialReprojectedTable = (IJdbcSpatialTable) reprojectedTable; assertEquals(2154, spatialReprojectedTable.getSrid()); @@ -166,7 +166,7 @@ void testReproject() throws SQLException, Exception { @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - void testSaveQueryInFile() throws SQLException, Exception { + void testSaveQueryInFile() throws Exception { postGIS.execute(" DROP TABLE IF EXISTS orbisgis, query_table;" + "CREATE TABLE orbisgis (id int, the_geom geometry(point, 4326));" + "INSERT INTO orbisgis VALUES (1, 'SRID=4326;POINT(10 10)'::GEOMETRY), " + @@ -180,7 +180,7 @@ void testSaveQueryInFile() throws SQLException, Exception { IJdbcTable queryTable = postGIS.getTable(postGIS.load("target/query_table.shp")); assertNotNull(queryTable); assertEquals(2, queryTable.getRowCount()); - assertTrue(queryTable instanceof IJdbcSpatialTable); + assertInstanceOf(IJdbcSpatialTable.class, queryTable); IJdbcSpatialTable spatialReprojectedTable = (IJdbcSpatialTable) queryTable; assertEquals(4326, spatialReprojectedTable.getSrid()); @@ -188,7 +188,7 @@ void testSaveQueryInFile() throws SQLException, Exception { IJdbcSpatialTable spLoaded = postGIS.getSpatialTable("QUERY_TABLE"); assertEquals(2, spLoaded.getRowCount()); assertEquals(4326, spLoaded.getSrid()); - assertTrue(spLoaded.getFirstRow().get(1) instanceof Point); + assertInstanceOf(Point.class, spLoaded.getFirstRow().get(1)); } /** * Test the {@link JdbcSpatialTable#isSpatial()} method. @@ -276,7 +276,7 @@ public void testGetExtend() throws Exception { */ @Test @EnabledIfSystemProperty(named = "test.postgis", matches = "true") - public void testGetEstimatedExtend() throws SQLException, Exception { + public void testGetEstimatedExtend() throws Exception { postGIS.execute("VACUUM ANALYZE"); assertEquals(1, postGIS.getSpatialTable(TABLE_NAME).getEstimatedExtent().getLength(), 0.01); } diff --git a/process/src/main/java/org/orbisgis/process/GroovyProcessManager.java b/process/src/main/java/org/orbisgis/process/GroovyProcessManager.java index 00a9cd22..3a7a85de 100644 --- a/process/src/main/java/org/orbisgis/process/GroovyProcessManager.java +++ b/process/src/main/java/org/orbisgis/process/GroovyProcessManager.java @@ -58,7 +58,7 @@ public abstract class GroovyProcessManager extends Script implements IProcessMan /** * Internal ProcessManager. */ - private IProcessManager pm = new ProcessManager(); + private final IProcessManager pm = new ProcessManager(); /** * MetaClass use for groovy methods/properties binding */ diff --git a/process/src/test/java/org/orbisgis/process/GroovyProcessManagerTest.java b/process/src/test/java/org/orbisgis/process/GroovyProcessManagerTest.java index f0691d19..9d953065 100644 --- a/process/src/test/java/org/orbisgis/process/GroovyProcessManagerTest.java +++ b/process/src/test/java/org/orbisgis/process/GroovyProcessManagerTest.java @@ -171,7 +171,7 @@ void metaClassTest() { void invokeMethodTest() { GroovyProcessManager pm = new DummyGPM(); assertNotNull(pm.invokeMethod("create", cl)); - assertTrue(pm.invokeMethod("create", cl) instanceof IProcess); + assertInstanceOf(IProcess.class, pm.invokeMethod("create", cl)); assertNull(pm.invokeMethod("process", "null")); assertNotNull(pm.invokeMethod("factory", null)); assertNull(pm.invokeMethod(null, null)); @@ -227,10 +227,10 @@ void registerTest() { void propertyTest() { GroovyProcessManager pm = new DummyGPM(); assertNull(pm.getProperty(null)); - assertTrue(pm.getProperty("pm") instanceof ProcessManager); + assertInstanceOf(ProcessManager.class, pm.getProperty("pm")); pm.registerFactory("toto1", new ProcessFactory()); - assertTrue(pm.getProperty("toto1") instanceof ProcessFactory); + assertInstanceOf(ProcessFactory.class, pm.getProperty("toto1")); assertThrows(MissingPropertyExceptionNoStack.class, () -> pm.getProperty("not a property")); } diff --git a/process/src/test/java/org/orbisgis/process/ProcessManagerTest.java b/process/src/test/java/org/orbisgis/process/ProcessManagerTest.java index 88e31819..bc7eb1c7 100644 --- a/process/src/test/java/org/orbisgis/process/ProcessManagerTest.java +++ b/process/src/test/java/org/orbisgis/process/ProcessManagerTest.java @@ -185,7 +185,7 @@ void metaClassTest() { void invokeMethodTest() { ProcessManager pm = ProcessManager.getProcessManager(); assertNotNull(pm.invokeMethod("create", cl)); - assertTrue(pm.invokeMethod("create", cl) instanceof IProcess); + assertInstanceOf(IProcess.class, pm.invokeMethod("create", cl)); assertNull(pm.invokeMethod("process", "null")); assertNotNull(pm.invokeMethod("factory", null)); assertNull(pm.invokeMethod(null, null)); diff --git a/process/src/test/java/org/orbisgis/process/ProcessTest.java b/process/src/test/java/org/orbisgis/process/ProcessTest.java index 7b7f1261..3636da2f 100644 --- a/process/src/test/java/org/orbisgis/process/ProcessTest.java +++ b/process/src/test/java/org/orbisgis/process/ProcessTest.java @@ -391,13 +391,13 @@ void invokeMethodTest() { */ @Test void getPropertyTest() { - assertTrue(fullProcess.getProperty("in1") instanceof IInput); - assertTrue(fullProcess.getProperty("in2") instanceof IInput); - assertTrue(fullProcess.getProperty("in3") instanceof IInput); - assertTrue(fullProcess.getProperty("in4") instanceof IInput); - assertTrue(fullProcess.getProperty("out1") instanceof IOutput); - assertTrue(fullProcess.getProperty("out2") instanceof IOutput); - assertTrue(fullProcess.getProperty("out3") instanceof IOutput); + assertInstanceOf(IInput.class, fullProcess.getProperty("in1")); + assertInstanceOf(IInput.class, fullProcess.getProperty("in2")); + assertInstanceOf(IInput.class, fullProcess.getProperty("in3")); + assertInstanceOf(IInput.class, fullProcess.getProperty("in4")); + assertInstanceOf(IOutput.class, fullProcess.getProperty("out1")); + assertInstanceOf(IOutput.class, fullProcess.getProperty("out2")); + assertInstanceOf(IOutput.class, fullProcess.getProperty("out3")); assertEquals("title", fullProcess.getProperty("title")); assertNull(fullProcess.getProperty(null)); diff --git a/process/src/test/java/org/orbisgis/process/ProgressMonitorTest.java b/process/src/test/java/org/orbisgis/process/ProgressMonitorTest.java index 996c56da..3c023468 100644 --- a/process/src/test/java/org/orbisgis/process/ProgressMonitorTest.java +++ b/process/src/test/java/org/orbisgis/process/ProgressMonitorTest.java @@ -106,7 +106,7 @@ public void progressWithMaxTest(){ pm.incrementStep(); p++; - assertEquals(round(100.0 / 7.0 * 1.0), round(pm.getProgress())); + assertEquals(round(100.0 / 7.0), round(pm.getProgress())); IProgressMonitor subPm1 = pm.getSubProgress("sub1", 4, false); assertNotNull(subPm1); diff --git a/process/src/test/java/org/orbisgis/process/check/ProcessCheckTest.java b/process/src/test/java/org/orbisgis/process/check/ProcessCheckTest.java index 8d0d49b9..b2c2ebfd 100644 --- a/process/src/test/java/org/orbisgis/process/check/ProcessCheckTest.java +++ b/process/src/test/java/org/orbisgis/process/check/ProcessCheckTest.java @@ -333,19 +333,19 @@ public void propertyTest() { processCheck.setProperty("inOutPuts", null); Object obj = processCheck.getProperty("inOutPuts"); assertFalse(obj instanceof Optional); - assertTrue(obj instanceof LinkedList); + assertInstanceOf(LinkedList.class, obj); assertTrue(((LinkedList) obj).isEmpty()); processCheck.setProperty("inOutPuts", new IInOutPut[]{new Input()}); obj = processCheck.getProperty("inOutPuts"); assertFalse(obj instanceof Optional); - assertTrue(obj instanceof LinkedList); + assertInstanceOf(LinkedList.class, obj); assertEquals(1, ((LinkedList)obj).size()); processCheck.setMetaClass(null); processCheck.setProperty("inOutPuts", null); obj = processCheck.getProperty("inOutPuts"); - assertTrue(obj instanceof LinkedList); + assertInstanceOf(LinkedList.class, obj); processCheck.setMetaClass(InvokerHelper.getMetaClass(processCheck.getClass())); obj = processCheck.getProperty("inOutPuts"); diff --git a/process/src/test/java/org/orbisgis/process/inoutput/InOutPutTest.java b/process/src/test/java/org/orbisgis/process/inoutput/InOutPutTest.java index bc29dcf7..152b5faf 100644 --- a/process/src/test/java/org/orbisgis/process/inoutput/InOutPutTest.java +++ b/process/src/test/java/org/orbisgis/process/inoutput/InOutPutTest.java @@ -59,7 +59,7 @@ public class InOutPutTest { void nameTest() { DummyInOutPut dummyInOutPut = new DummyInOutPut(); assertFalse(dummyInOutPut.getName().isPresent()); - assertTrue(dummyInOutPut.name("name") instanceof InOutPut); + assertInstanceOf(InOutPut.class, dummyInOutPut.name("name")); assertTrue(dummyInOutPut.getName().isPresent()); assertEquals("name", dummyInOutPut.getName().get()); dummyInOutPut.setName(null); @@ -74,7 +74,7 @@ void processTest() { IProcess process = ProcessManager.createFactory().create().getProcess(); DummyInOutPut dummyInOutPut = new DummyInOutPut(); assertFalse(dummyInOutPut.getProcess().isPresent()); - assertTrue(dummyInOutPut.process(process) instanceof InOutPut); + assertInstanceOf(InOutPut.class, dummyInOutPut.process(process)); assertTrue(dummyInOutPut.getProcess().isPresent()); assertEquals(process, dummyInOutPut.getProcess().get()); dummyInOutPut.setProcess(null); @@ -88,7 +88,7 @@ void processTest() { void titleTest() { DummyInOutPut dummyInOutPut = new DummyInOutPut(); assertFalse(dummyInOutPut.getTitle().isPresent()); - assertTrue(dummyInOutPut.title("title") instanceof InOutPut); + assertInstanceOf(InOutPut.class, dummyInOutPut.title("title")); assertTrue(dummyInOutPut.getTitle().isPresent()); assertEquals("title", dummyInOutPut.getTitle().get()); dummyInOutPut.setTitle(null); @@ -102,7 +102,7 @@ void titleTest() { void descriptionTest() { DummyInOutPut dummyInOutPut = new DummyInOutPut(); assertFalse(dummyInOutPut.getDescription().isPresent()); - assertTrue(dummyInOutPut.description("descr") instanceof InOutPut); + assertInstanceOf(InOutPut.class, dummyInOutPut.description("descr")); assertTrue(dummyInOutPut.getDescription().isPresent()); assertEquals("descr", dummyInOutPut.getDescription().get()); dummyInOutPut.setDescription(null); @@ -116,7 +116,7 @@ void descriptionTest() { void keywordsTest() { DummyInOutPut dummyInOutPut = new DummyInOutPut(); assertFalse(dummyInOutPut.getKeywords().isPresent()); - assertTrue(dummyInOutPut.keywords(new String[]{"key1", "key2"}) instanceof InOutPut); + assertInstanceOf(InOutPut.class, dummyInOutPut.keywords(new String[]{"key1", "key2"})); assertTrue(dummyInOutPut.getKeywords().isPresent()); assertArrayEquals(new String[]{"key1", "key2"}, dummyInOutPut.getKeywords().get()); dummyInOutPut.setKeywords(null); @@ -130,7 +130,7 @@ void keywordsTest() { void typeTest() { DummyInOutPut dummyInOutPut = new DummyInOutPut(); assertFalse(dummyInOutPut.getType().isPresent()); - assertTrue(dummyInOutPut.type(Integer.class) instanceof InOutPut); + assertInstanceOf(InOutPut.class, dummyInOutPut.type(Integer.class)); assertTrue(dummyInOutPut.getType().isPresent()); assertEquals(Integer.class, dummyInOutPut.getType().get()); dummyInOutPut.setType(null);