/** Test if Issues are (De)serialiazed properly */ @Test public void testSerDeser() throws IOException { String issueStr = "{\"explanation\" : \"myex\", \"type\" : { \"major\" : \"maj\", \"minor\": \"min\" }, \"severity\" : 75, \"url\": \"www.cnn.com\"}"; Issue issue = BatfishObjectMapper.mapper().readValue(issueStr, Issue.class); // check if the issue is properly deserialized assertThat(issue.getExplanation(), equalTo("myex")); assertThat(issue.getType().getMajor(), equalTo("maj")); assertThat(issue.getType().getMinor(), equalTo("min")); assertThat(issue.getSeverity(), equalTo(75)); assertThat(issue.getUrl(), equalTo("www.cnn.com")); String issueSer = BatfishObjectMapper.mapper().writeValueAsString(issue); ObjectNode issueObj = (ObjectNode) BatfishObjectMapper.mapper().readTree(issueSer); // check serialization assertThat(issueObj.get("explanation").asText(), equalTo("myex")); assertThat(issueObj.get("severity").asInt(), equalTo(75)); assertThat(issueObj.get("url").asText(), equalTo("www.cnn.com")); assertThat(issueObj.get("type").get("major").asText(), equalTo("maj")); assertThat(issueObj.get("type").get("minor").asText(), equalTo("min")); } }
newIssue = new Issue( oldIssue.getExplanation(), minorConfig.getSeverity(), oldIssue.getType(),
@Test public void testApplyRowIssuesConfigurationMatch() { String col = "col"; String major = "major"; String minor = "minor"; Issue oldIssue = new Issue("explanation", 5, new Issue.Type(major, minor)); Row oldRow = Row.of(col, oldIssue); int newSeverity = 6; String newUrl = "example.com"; Issue newIssue = new Issue(oldIssue.getExplanation(), newSeverity, oldIssue.getType(), newUrl); Set<String> issueColumns = ImmutableSet.of(col); Map<String, MajorIssueConfig> issueConfigs = ImmutableMap.of( major, new MajorIssueConfig(major, ImmutableList.of(new MinorIssueConfig(minor, 6, newUrl)))); assertThat( _manager.applyRowIssuesConfiguration(oldRow, issueColumns, issueConfigs), equalTo(Row.of(col, newIssue))); }