RedmineGovernorRecorder { public void redmineReportEntries(@Observes After event) { final Method testMethod = event.getTestMethod(); final TestClass testClass = event.getTestClass(); final String redmineServerURL = redmineGovernorConfigurationInstance.get().getServer(); final Redmine redmineValue = getRedmineValue(testMethod, testClass); if (redmineValue != null) { final String issueURL = constructRedmineIssueURL(redmineServerURL, redmineValue.value()); final TableEntry redmineDetector = new TableEntry(); redmineDetector.setTableName("RedmineOptions"); redmineDetector.getTableHead().getRow().addCells(new TableCellEntry("Force")); final TableRowEntry row = new TableRowEntry(); row.addCells(new TableCellEntry(String.valueOf(redmineValue.force()))); redmineDetector.getTableBody().addRow(row); propertyReportEvent.fire(new PropertyReportEvent(new KeyValueEntry("Redmine URL", issueURL))); propertyReportEvent.fire(new PropertyReportEvent(redmineDetector)); } }  void setRedmineGovernorConfigurationInstance(Instance<RedmineGovernorConfiguration> redmineGovernorConfigurationInstance); void setPropertyReportEvent(Event<PropertyReportEvent> propertyReportEvent); void redmineReportEntries(@Observes After event);  }
@Test public void shouldReportRedmineGovernorParamsForMethod() { After after = new After(new FakeTestClass(), getMethod("dummyTest")); redmineGovernorRecorder.redmineReportEntries(after); verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture()); List<PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues(); KeyValueEntry redmineURL = new KeyValueEntry("Redmine URL","http: LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>(); tableOptions.put("Force","false"); assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(redmineURL); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("RedmineOptions", tableOptions)); }
@Test public void sholdReportRedmineGovernorParamsForClass(){ After after = new After(new FakeTestClass(), getMethod("someTestMethod")); redmineGovernorRecorder.redmineReportEntries(after); verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture()); List <PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues(); KeyValueEntry redmineURL = new KeyValueEntry("Redmine URL","http: LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>(); tableOptions.put("Force","true"); assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(redmineURL); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("RedmineOptions", tableOptions)); }