@Test public void testReferentialFileRulesWithWhiteSpace() throws IOException, InvalidParseOperationException { final ArrayNode arrayNode = RulesManagerParser.readObjectsFromCsvWriteAsArrayNode(PropertiesUtils.findFile(REFERENTIAL_KO_WHITESPACE)); String ruleId = JsonHandler.prettyPrint(arrayNode.get(0).get("RuleId")); assertFalse(ruleId.contains(" ")); ruleId = JsonHandler.unprettyPrint(arrayNode.get(1).get("RuleId")); assertFalse(ruleId.contains(" ")); ruleId = JsonHandler.unprettyPrint(arrayNode.get(2).get("RuleId")); assertFalse(ruleId.contains(" ")); }
public static ArrayNode readObjectsFromCsvWriteAsArrayNode(File fileToParse) throws IOException, InvalidParseOperationException { final CsvSchema bootstrap = CsvSchema.emptySchema().withHeader(); final CsvMapper csvMapper = new CsvMapper(); final MappingIterator<Map<?, ?>> mappingIterator = csvMapper.readerFor(Map.class).with(bootstrap).readValues(fileToParse); final ArrayNode arrayNode = JsonHandler.createArrayNode(); final List<Map<?, ?>> data = mappingIterator.readAll(); for (Map<?, ?> c : data) { final JsonNode node = JsonHandler.toJsonNode(c); String ruleId = node.get("RuleId").asText(); String escaped = ruleId.replaceAll("\"", " "); String trimmed = escaped.trim(); final ObjectNode result = (ObjectNode) node; result.put("RuleId", trimmed); result.put(CREATION_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); result.put(UPDATE_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); arrayNode.add(result); } return arrayNode; }
RulesManagerParser { public static ArrayNode readObjectsFromCsvWriteAsArrayNode(File fileToParse) throws IOException, InvalidParseOperationException { final CsvSchema bootstrap = CsvSchema.emptySchema().withHeader(); final CsvMapper csvMapper = new CsvMapper(); final MappingIterator<Map<?, ?>> mappingIterator = csvMapper.readerFor(Map.class).with(bootstrap).readValues(fileToParse); final ArrayNode arrayNode = JsonHandler.createArrayNode(); final List<Map<?, ?>> data = mappingIterator.readAll(); for (Map<?, ?> c : data) { final JsonNode node = JsonHandler.toJsonNode(c); String ruleId = node.get("RuleId").asText(); String escaped = ruleId.replaceAll("\"", " "); String trimmed = escaped.trim(); final ObjectNode result = (ObjectNode) node; result.put("RuleId", trimmed); result.put(CREATION_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); result.put(UPDATE_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); arrayNode.add(result); } return arrayNode; } }
RulesManagerParser { public static ArrayNode readObjectsFromCsvWriteAsArrayNode(File fileToParse) throws IOException, InvalidParseOperationException { final CsvSchema bootstrap = CsvSchema.emptySchema().withHeader(); final CsvMapper csvMapper = new CsvMapper(); final MappingIterator<Map<?, ?>> mappingIterator = csvMapper.readerFor(Map.class).with(bootstrap).readValues(fileToParse); final ArrayNode arrayNode = JsonHandler.createArrayNode(); final List<Map<?, ?>> data = mappingIterator.readAll(); for (Map<?, ?> c : data) { final JsonNode node = JsonHandler.toJsonNode(c); String ruleId = node.get("RuleId").asText(); String escaped = ruleId.replaceAll("\"", " "); String trimmed = escaped.trim(); final ObjectNode result = (ObjectNode) node; result.put("RuleId", trimmed); result.put(CREATION_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); result.put(UPDATE_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); arrayNode.add(result); } return arrayNode; } RulesManagerParser(); }
RulesManagerParser { public static ArrayNode readObjectsFromCsvWriteAsArrayNode(File fileToParse) throws IOException, InvalidParseOperationException { final CsvSchema bootstrap = CsvSchema.emptySchema().withHeader(); final CsvMapper csvMapper = new CsvMapper(); final MappingIterator<Map<?, ?>> mappingIterator = csvMapper.readerFor(Map.class).with(bootstrap).readValues(fileToParse); final ArrayNode arrayNode = JsonHandler.createArrayNode(); final List<Map<?, ?>> data = mappingIterator.readAll(); for (Map<?, ?> c : data) { final JsonNode node = JsonHandler.toJsonNode(c); String ruleId = node.get("RuleId").asText(); String escaped = ruleId.replaceAll("\"", " "); String trimmed = escaped.trim(); final ObjectNode result = (ObjectNode) node; result.put("RuleId", trimmed); result.put(CREATION_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); result.put(UPDATE_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); arrayNode.add(result); } return arrayNode; } RulesManagerParser(); static ArrayNode readObjectsFromCsvWriteAsArrayNode(File fileToParse); }
RulesManagerParser { public static ArrayNode readObjectsFromCsvWriteAsArrayNode(File fileToParse) throws IOException, InvalidParseOperationException { final CsvSchema bootstrap = CsvSchema.emptySchema().withHeader(); final CsvMapper csvMapper = new CsvMapper(); final MappingIterator<Map<?, ?>> mappingIterator = csvMapper.readerFor(Map.class).with(bootstrap).readValues(fileToParse); final ArrayNode arrayNode = JsonHandler.createArrayNode(); final List<Map<?, ?>> data = mappingIterator.readAll(); for (Map<?, ?> c : data) { final JsonNode node = JsonHandler.toJsonNode(c); String ruleId = node.get("RuleId").asText(); String escaped = ruleId.replaceAll("\"", " "); String trimmed = escaped.trim(); final ObjectNode result = (ObjectNode) node; result.put("RuleId", trimmed); result.put(CREATION_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); result.put(UPDATE_DATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); arrayNode.add(result); } return arrayNode; } RulesManagerParser(); static ArrayNode readObjectsFromCsvWriteAsArrayNode(File fileToParse);  }