### Question:
CcCourtChartXSettingsGenerator implements XSettingsGenerator { @Override public boolean canGenerateXSettings(JudgmentGlobalFilter judgmentGlobalFilter) { Preconditions.checkNotNull(judgmentGlobalFilter); CourtCriteria courtCriteria = judgmentGlobalFilter.getCourtCriteria(); if (CourtType.COMMON != courtCriteria.getCourtType()) { return false; } if (courtCriteria.getCcCourtId() == null) { return true; }; if (!courtCriteria.isCcIncludeDependentCourtJudgments()) { return false; } CommonCourt commonCourt = commonCourtRepository.findOne(courtCriteria.getCcCourtId()); if (CommonCourtType.DISTRICT == commonCourt.getType()) { return false; } return true; }  @Override XSettings generateXSettings(JudgmentGlobalFilter judgmentGlobalFilter); @Override boolean canGenerateXSettings(JudgmentGlobalFilter judgmentGlobalFilter); @Override boolean handles(ChartCode chartCode); @Autowired void setCommonCourtRepository(CommonCourtRepository commonCourtRepository);  }### Answer:
@Test(expected = NullPointerException.class) public void canGenerateXSettings_NULL() { xsettingsGenerator.canGenerateXSettings(null); }
@Test public void canGenerateXSettings_FALSE_EmptyCourtCriteria() { JudgmentGlobalFilter globalFilter = new JudgmentGlobalFilter(); assertFalse(xsettingsGenerator.canGenerateXSettings(globalFilter)); }
@Test public void canGenerateXSettings_FALSE_CourtTypeNotCommon() { JudgmentGlobalFilter globalFilter = new JudgmentGlobalFilter(); globalFilter.getCourtCriteria().setCourtType(CourtType.CONSTITUTIONAL_TRIBUNAL); assertFalse(xsettingsGenerator.canGenerateXSettings(globalFilter)); }
@Test public void canGenerateXSettings_FALSE_CourtTypeCommon_CourtIdNotNull_IncludeDependentFALSE() { JudgmentGlobalFilter globalFilter = new JudgmentGlobalFilter(); globalFilter.getCourtCriteria().setCourtType(CourtType.COMMON); globalFilter.getCourtCriteria().setCcCourtId(12L); globalFilter.getCourtCriteria().setCcIncludeDependentCourtJudgments(false); assertFalse(xsettingsGenerator.canGenerateXSettings(globalFilter)); }
@Test public void canGenerateXSettings_FALSE_CourtTypeCommon_CourtIdNotNull_IncludeDependentTRUE_District() { JudgmentGlobalFilter globalFilter = new JudgmentGlobalFilter(); globalFilter.getCourtCriteria().setCourtType(CourtType.COMMON); globalFilter.getCourtCriteria().setCcCourtId(12L); globalFilter.getCourtCriteria().setCcIncludeDependentCourtJudgments(true); CommonCourt commonCourt = new CommonCourt(); commonCourt.setType(CommonCourtType.DISTRICT); when(commonCourtRepository.findOne(12L)).thenReturn(commonCourt); assertFalse(xsettingsGenerator.canGenerateXSettings(globalFilter)); }
@Test public void canGenerateXSettings_TRUE_CourtTypeCommon_CourtIdNull() { JudgmentGlobalFilter globalFilter = new JudgmentGlobalFilter(); globalFilter.getCourtCriteria().setCourtType(CourtType.COMMON); globalFilter.getCourtCriteria().setCcCourtId(null); assertTrue(xsettingsGenerator.canGenerateXSettings(globalFilter)); }
@Test public void canGenerateXSettings_TRUE_CourtTypeCommon_CourtIdNotNull_IncludeDependentTRUE_NotDistrict() { JudgmentGlobalFilter globalFilter = new JudgmentGlobalFilter(); globalFilter.getCourtCriteria().setCourtType(CourtType.COMMON); globalFilter.getCourtCriteria().setCcCourtId(12L); globalFilter.getCourtCriteria().setCcIncludeDependentCourtJudgments(true); CommonCourt commonCourt = new CommonCourt(); commonCourt.setType(CommonCourtType.APPEAL); when(commonCourtRepository.findOne(12L)).thenReturn(commonCourt); assertTrue(xsettingsGenerator.canGenerateXSettings(globalFilter)); }