JiraGovernorRecorder { public void jiraReportEntries(@Observes After event) { final Method method = event.getTestMethod(); final TestClass testClass = event.getTestClass(); final String jiraServer = jiraGovernorConfigurationInstance.get().getServer(); final Jira jira = getJiraValue(method, testClass); if (jira != null) { final String issueURL = constructJiraIssueURL(jiraServer, jira.value()); final Class<? extends Detectable>[] detectables = jira.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 jiraDetector = new TableEntry(); jiraDetector.setTableName("JiraOptions"); jiraDetector.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(jira.force())), new TableCellEntry(String.valueOf(jira.detector().strategy().getSimpleName())), new TableCellEntry(detectablesName) ); jiraDetector.getTableBody().addRow(row); propertyReportEvent.fire(new PropertyReportEvent(new KeyValueEntry("JIRA URL", issueURL))); propertyReportEvent.fire(new PropertyReportEvent(jiraDetector)); } }  void setJiraGovernorConfigurationInstance(Instance<JiraGovernorConfiguration> jiraGovernorConfigurationInstance); void setPropertyReportEvent(Event<PropertyReportEvent> propertyReportEvent); void jiraReportEntries(@Observes After event);  }
@Test public void shouldReportJiraGovernorParamsForMethod() { After after = new After(new FakeTestClass(), getMethod("dummyTest")); jiraGovernorRecorder.jiraReportEntries(after); verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture()); List <PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues(); KeyValueEntry keyValueEntry = new KeyValueEntry("JIRA URL","https: LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>(); tableOptions.put("Force", "true"); tableOptions.put("Detector Value", "And"); tableOptions.put("Detector Strategy", "Unix"); assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(keyValueEntry); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("JiraOptions", tableOptions)); }
@Test public void sholdReportJiraGovernorParamsForClass(){ After after = new After(new FakeTestClass(), getMethod("someTestMethod")); jiraGovernorRecorder.jiraReportEntries(after); verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture()); List <PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues(); KeyValueEntry jiraURL = new KeyValueEntry("JIRA URL","https: LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>(); tableOptions.put("Force", "false"); tableOptions.put("Detector Value", "And"); tableOptions.put("Detector Strategy", "Windows"); assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(jiraURL); assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("JiraOptions", tableOptions)); }