GitHubGovernorRecorder { public void gitHubReportEntries(@Observes After event) { final Method testMethod = event.getTestMethod(); final TestClass testClass = event.getTestClass(); final GitHub gitHubValue = getGitHubValue(testMethod, testClass); if (gitHubValue != null) { final GitHubGovernorConfiguration configuration = gitHubGovernorConfigurationInstance.get(); final String gitHubIssueURL = contructGitHubIssueURL(configuration, gitHubValue); final Class<? extends Detectable>[] detectables = gitHubValue.detector().value(); final Set<String> uniqDetectables = new TreeSet<String>(); for (final Class<? extends Detectable> detectable : detectables) { uniqDetectables.add(detectable.getSimpleName()); } String detectablesName = ""; for (final String detectable : uniqDetectables) { detectablesName += (detectablesName == "" ? "" : ",") + detectable; } final TableEntry gitHubDetector = new TableEntry(); gitHubDetector.setTableName("GitHubOptions"); gitHubDetector.getTableHead().getRow().addCells(new TableCellEntry("Force"), new TableCellEntry("Detector Value"), new TableCellEntry("Detector Strategy")); final TableRowEntry row = new TableRowEntry(); row.addCells(new TableCellEntry(String.valueOf(gitHubValue.force())), new TableCellEntry(String.valueOf(gitHubValue.detector().strategy().getSimpleName())), new TableCellEntry(detectablesName)); gitHubDetector.getTableBody().addRow(row); propertyReportEvent.fire(new PropertyReportEvent(new KeyValueEntry("GitHub URL", gitHubIssueURL))); propertyReportEvent.fire(new PropertyReportEvent(gitHubDetector)); } }  void setGitHubGovernorConfigurationInstance(Instance<GitHubGovernorConfiguration> gitHubGovernorConfigurationInstance); void setPropertyReportEvent(Event<PropertyReportEvent> propertyReportEvent); void gitHubReportEntries(@Observes After event);  }
@Test public void shouldReportGitHubGovernorParamsForMethod() { After after = new After(new FakeTestClass(), getMethod("dummyTest")); gitHubGovernorRecorder.gitHubReportEntries(after); verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture()); List<PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues(); KeyValueEntry gitHubURL = new KeyValueEntry("GitHub URL","https: LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>(); tableOptions.put("Force", "false"); tableOptions.put("Detector Value", "And"); tableOptions.put("Detector Strategy", "True"); assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(gitHubURL); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("GitHubOptions", tableOptions)); }
@Test public void sholdReportGitHubGovernorParamsForClass(){ After after = new After(new FakeTestClass(), getMethod("someTestMethod")); gitHubGovernorRecorder.gitHubReportEntries(after); verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture()); List<PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues(); KeyValueEntry gitHubURL = new KeyValueEntry("GitHub URL","https: LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>(); tableOptions.put("Force", "true"); tableOptions.put("Detector Value", "And"); tableOptions.put("Detector Strategy", "True"); assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(gitHubURL); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("GitHubOptions", tableOptions)); }