public void getColumnTypes() { ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(INDICES, INDICES); table.put(0, 0, Result.success(1)); table.put(0, 1, Result.success("abc")); table.put(1, 0, Result.success(2)); table.put(1, 1, Result.success("def")); List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table)); assertThat(columnTypes).isEqualTo(ImmutableList.of(Integer.class, String.class)); }
public void getColumnTypesWithAllFailures() { ImmutableList<Integer> indices = ImmutableList.of(0, 1); ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(indices, indices); table.put(0, 0, Result.failure(FailureReason.ERROR, "fail")); table.put(0, 1, Result.failure(FailureReason.ERROR, "fail")); table.put(1, 0, Result.failure(FailureReason.ERROR, "fail")); table.put(1, 1, Result.failure(FailureReason.ERROR, "fail")); List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table)); assertThat(columnTypes).isEqualTo(ImmutableList.of(Object.class, Object.class)); }
@Test public void getTable_TableGotten_TableCorrect() { // tbl1 = table // rgd1 = table array format Double[][] rgd1; ArrayTable<GraphVertex, GraphVertex, Double> tbl1; tbl1 = spw1.getTable(); rgd1 = tbl1.toArray(Double.class); for (SpatialWeightsMatrix.GraphEdge edg1 : spw1.getEdges()) { assertEquals(spw1.getWeight(edg1), tbl1.get(edg1.vtxStart, edg1.vtxEnd), 0.000001); } assertEquals(tbl1.rowKeySet().size(), spw1.getVertices().size()); for (int i = 0; i < tbl1.rowKeyList().size(); i++) { for (int j = 0; j < tbl1.columnKeyList().size(); j++) { if (spw1.containsEdge(tbl1.rowKeyList().get(i).iID, tbl1.columnKeyList().get(j).iID)) { assertEquals( rgd1[i][j], spw1.getEdge(tbl1.rowKeyList().get(i).iID, tbl1.columnKeyList().get(j).iID) .getDouble("dWeight"), 0.000001); assertEquals( tbl1.get(tbl1.rowKeyList().get(i), tbl1.columnKeyList().get(j)), spw1.getEdge(tbl1.rowKeyList().get(i).iID, tbl1.columnKeyList().get(j).iID) .getDouble("dWeight"), 0.000001); } else { assertEquals(rgd1[i][j], 0., 0.0000001); assertEquals( tbl1.get(tbl1.rowKeyList().get(i), tbl1.columnKeyList().get(j)), 0, 0.000001); } } } }