SpreadsheetUtils { public static String getPortName(String columnLabel, JsonNode jsonNode) { String portName = columnLabel; if (jsonNode != null && jsonNode.has("columnNames")) { for (JsonNode mappingNode : jsonNode.get("columnNames")) { if (columnLabel.equals(mappingNode.get("column").textValue())) { portName = mappingNode.get("port").textValue(); break; } } } return portName; }  static int getColumnIndex(String column); static String getColumnLabel(int column); static String getPortName(String columnLabel, JsonNode jsonNode); static String getPortName(int columnIndex, JsonNode jsonNode); static Range getRange(JsonNode jsonNode);  }
@Test public void testGetPortNameStringMapOfStringString() { assertEquals("A", SpreadsheetUtils.getPortName("A", null)); assertEquals("AABR", SpreadsheetUtils.getPortName("AABR", null)); ObjectNode configuration = JsonNodeFactory.instance.objectNode(); ArrayNode columnNames = configuration.arrayNode(); columnNames.addObject().put("column", "B").put("port", "beta"); configuration.put("columnNames", columnNames); assertEquals("beta", SpreadsheetUtils.getPortName("B", configuration)); assertEquals("T", SpreadsheetUtils.getPortName("T", configuration)); }
@Test public void testGetPortNameIntMapOfStringString() { assertEquals("A", SpreadsheetUtils.getPortName(0, null)); assertEquals("AA", SpreadsheetUtils.getPortName(26, null)); ObjectNode configuration = JsonNodeFactory.instance.objectNode(); ArrayNode columnNames = configuration.arrayNode(); columnNames.addObject().put("column", "D").put("port", "delta"); configuration.put("columnNames", columnNames); assertEquals("delta", SpreadsheetUtils.getPortName(3, configuration)); assertEquals("AB", SpreadsheetUtils.getPortName(27, configuration)); }