TadDao { public List<TopologicalDomain> getAllTads() { try (Connection connection = dataSource.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("select CHROMOSOME as chr, START as start, \"end\" as end, ENTREZID as geneId, SYMBOL as geneSymbol from tad"); ResultSet rs = preparedStatement.executeQuery()) { return createTads(rs); } catch (SQLException e) { logger.error("Error executing topologically associated domain query: ", e); } return Collections.emptyList(); } TadDao(DataSource genomeDataSource); List<TopologicalDomain> getAllTads();  }
@Test public void testGetAllTads() { Map<String, Integer> genes1 = new LinkedHashMap<>(); genes1.put("ISG15", 9636); genes1.put("TNFRSF4", 7293); TopologicalDomain tad1 = new TopologicalDomain(1, 770137, 1250137, genes1); Map<String, Integer> genes2 = new LinkedHashMap<>(); genes2.put("MMP23B", 8510); TopologicalDomain tad2 = new TopologicalDomain(1, 1250137, 1850140, genes2); Map<String, Integer> genes3 = new LinkedHashMap<>(); genes3.put("LBH", 81606); genes3.put("LCLAT1", 253558); genes3.put("YPEL5", 51646); TopologicalDomain tad3 = new TopologicalDomain(2, 30346496, 30906496, genes3); Map<String, Integer> genes4 = new LinkedHashMap<>(); genes4.put("GENE1", 11111); TopologicalDomain tad4 = new TopologicalDomain(2, 30346496, 30800000, genes4); Map<String, Integer> genes5 = new LinkedHashMap<>(); genes5.put("GENE2", 22222); TopologicalDomain tad5 = new TopologicalDomain(2, 30200000, 30800000, genes5); Map<String, Integer> genes6 = new LinkedHashMap<>(); genes6.put("GENE3", 33333); genes6.put("GENE4", 44444); TopologicalDomain tad6 = new TopologicalDomain(2, 30100000, 30600000, genes6); List<TopologicalDomain> expected = new ArrayList<>(); expected.add(tad1); expected.add(tad2); expected.add(tad3); expected.add(tad4); expected.add(tad5); expected.add(tad6); assertThat(instance.getAllTads(), equalTo(expected)); }