@Test public void toProblemStatus_should_compare_ignoring_case_with_CLOSED() { long aProjectId = 42; when(settingService.getList(aProjectId, Settings.DEFECT_RTC_CLOSED_STATES)) .thenReturn(Collections.singletonList("aAa")); when(settingService.getList(aProjectId, Settings.DEFECT_RTC_OPEN_STATES)) .thenReturn(Collections.singletonList("bBb")); final WorkItem workItemWithClosedUpperCasedState = new WorkItem().withState(new State().withName("Aaa")); final ProblemStatus status = cut.toProblemStatus(aProjectId, workItemWithClosedUpperCasedState); assertThat(status).isEqualTo(ProblemStatus.CLOSED); }
ProblemStatus toProblemStatus(long projectId, WorkItem workItem) { final String state = workItem.getState().getName(); final String lowerState = state.toLowerCase(); final List<String> closedStates = settingService.getList(projectId, Settings.DEFECT_RTC_CLOSED_STATES); final List<String> openStates = settingService.getList(projectId, Settings.DEFECT_RTC_OPEN_STATES); if (closedStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { if (openStates.contains(lowerState)) { log.error("Work item status \"{}\" is configured both as OPEN and CLOSED: CLOSED have priority", state); } return ProblemStatus.CLOSED; } else if (openStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { return ProblemStatus.OPEN; } log.error("Work item status \"{}\" is not configured as OPEN nor as CLOSED: consider it OPEN", state); return ProblemStatus.OPEN; }
RtcDefectAdapter implements DefectAdapter { ProblemStatus toProblemStatus(long projectId, WorkItem workItem) { final String state = workItem.getState().getName(); final String lowerState = state.toLowerCase(); final List<String> closedStates = settingService.getList(projectId, Settings.DEFECT_RTC_CLOSED_STATES); final List<String> openStates = settingService.getList(projectId, Settings.DEFECT_RTC_OPEN_STATES); if (closedStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { if (openStates.contains(lowerState)) { log.error("Work item status \"{}\" is configured both as OPEN and CLOSED: CLOSED have priority", state); } return ProblemStatus.CLOSED; } else if (openStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { return ProblemStatus.OPEN; } log.error("Work item status \"{}\" is not configured as OPEN nor as CLOSED: consider it OPEN", state); return ProblemStatus.OPEN; } }
RtcDefectAdapter implements DefectAdapter { ProblemStatus toProblemStatus(long projectId, WorkItem workItem) { final String state = workItem.getState().getName(); final String lowerState = state.toLowerCase(); final List<String> closedStates = settingService.getList(projectId, Settings.DEFECT_RTC_CLOSED_STATES); final List<String> openStates = settingService.getList(projectId, Settings.DEFECT_RTC_OPEN_STATES); if (closedStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { if (openStates.contains(lowerState)) { log.error("Work item status \"{}\" is configured both as OPEN and CLOSED: CLOSED have priority", state); } return ProblemStatus.CLOSED; } else if (openStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { return ProblemStatus.OPEN; } log.error("Work item status \"{}\" is not configured as OPEN nor as CLOSED: consider it OPEN", state); return ProblemStatus.OPEN; } @Autowired  RtcDefectAdapter(SettingService settingService,
                            RestTemplateBuilder restTemplateBuilder,
                            RtcDateTimeAdapter rtcDateTimeAdapter,
                            SettingProviderService settingProviderService); }
RtcDefectAdapter implements DefectAdapter { ProblemStatus toProblemStatus(long projectId, WorkItem workItem) { final String state = workItem.getState().getName(); final String lowerState = state.toLowerCase(); final List<String> closedStates = settingService.getList(projectId, Settings.DEFECT_RTC_CLOSED_STATES); final List<String> openStates = settingService.getList(projectId, Settings.DEFECT_RTC_OPEN_STATES); if (closedStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { if (openStates.contains(lowerState)) { log.error("Work item status \"{}\" is configured both as OPEN and CLOSED: CLOSED have priority", state); } return ProblemStatus.CLOSED; } else if (openStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { return ProblemStatus.OPEN; } log.error("Work item status \"{}\" is not configured as OPEN nor as CLOSED: consider it OPEN", state); return ProblemStatus.OPEN; } @Autowired  RtcDefectAdapter(SettingService settingService,
                            RestTemplateBuilder restTemplateBuilder,
                            RtcDateTimeAdapter rtcDateTimeAdapter,
                            SettingProviderService settingProviderService); @Override List<Defect> getStatuses(long projectId, List<String> ids); @Override List<Defect> getChangedDefects(long projectId, Date since); @Override boolean isValidId(long projectId, String id); @Override String getIdFormatHint(long projectId); @Override String getCode(); @Override String getName(); @Override List<SettingDTO> getSettingDefinitions(); }
RtcDefectAdapter implements DefectAdapter { ProblemStatus toProblemStatus(long projectId, WorkItem workItem) { final String state = workItem.getState().getName(); final String lowerState = state.toLowerCase(); final List<String> closedStates = settingService.getList(projectId, Settings.DEFECT_RTC_CLOSED_STATES); final List<String> openStates = settingService.getList(projectId, Settings.DEFECT_RTC_OPEN_STATES); if (closedStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { if (openStates.contains(lowerState)) { log.error("Work item status \"{}\" is configured both as OPEN and CLOSED: CLOSED have priority", state); } return ProblemStatus.CLOSED; } else if (openStates.stream().anyMatch(s -> s.equalsIgnoreCase(lowerState))) { return ProblemStatus.OPEN; } log.error("Work item status \"{}\" is not configured as OPEN nor as CLOSED: consider it OPEN", state); return ProblemStatus.OPEN; } @Autowired  RtcDefectAdapter(SettingService settingService,
                            RestTemplateBuilder restTemplateBuilder,
                            RtcDateTimeAdapter rtcDateTimeAdapter,
                            SettingProviderService settingProviderService); @Override List<Defect> getStatuses(long projectId, List<String> ids); @Override List<Defect> getChangedDefects(long projectId, Date since); @Override boolean isValidId(long projectId, String id); @Override String getIdFormatHint(long projectId); @Override String getCode(); @Override String getName(); @Override List<SettingDTO> getSettingDefinitions();  }