@Test
  public void testNoConflicts() {
    final ConfigurationData config = ValidatorTestData.createEmptyConfigurationWithDefaultGroup();

    checker.checkConflicts(config, bindingResult);

    Mockito.verifyZeroInteractions(bindingResult);
    assertEquals(GroupStatusType.DEFAULT, config.getGroups().get(0).getGroupStatus());
  }
  @Test
  public void testNoMandatoryFields() {
    final ConfigurationData config = ValidatorTestData.createConfigurationWithConflict(null);

    checker.checkMandatoryFields(config, bindingResult);

    Mockito.verify(bindingResult, times(0)).addError(Mockito.any(MandatoryFieldError.class));
    assertEquals(GroupStatusType.DEFAULT, config.getGroups().get(0).getGroupStatus());
  }
  @Test
  public void testMandatoryFields() {
    final ConfigurationData config = createMandatoryFieldConfiguration();

    checker.checkMandatoryFields(config, bindingResult);

    Mockito.verify(bindingResult, times(3)).addError(Mockito.any(MandatoryFieldError.class));
    assertEquals(GroupStatusType.WARNING, config.getGroups().get(0).getGroupStatus());
  }
  @Test
  public void testDoNotOverwriteErrorStatusOnGroup() {
    final ConfigurationData config =
        ValidatorTestData.createConfigurationWithConflict("a conflict");
    config.getGroups().get(0).setGroupStatus(GroupStatusType.ERROR);

    checker.checkConflicts(config, bindingResult);

    assertEquals(GroupStatusType.ERROR, config.getGroups().get(0).getGroupStatus());
  }
  @Test
  public void testWithConflictWithText() {
    final ConfigurationData config =
        ValidatorTestData.createConfigurationWithConflict("a conflict");

    checker.checkConflicts(config, bindingResult);

    Mockito.verify(bindingResult, times(1)).addError(Mockito.any(ConflictError.class));
    assertEquals(GroupStatusType.WARNING, config.getGroups().get(0).getGroupStatus());
  }
  @Test
  public void testMandatoryFieldsMultipleGroups() {
    final ConfigurationData config = createMandatoryFieldConfiguration();
    config.getGroups().add(ValidatorTestData.createGroupWithNumeric("2", "abc", "123"));

    checker.checkMandatoryFields(config, bindingResult);

    Mockito.verify(bindingResult, times(3)).addError(Mockito.any(MandatoryFieldError.class));
    assertEquals(GroupStatusType.WARNING, config.getGroups().get(0).getGroupStatus());
    assertEquals(GroupStatusType.DEFAULT, config.getGroups().get(1).getGroupStatus());
  }
  private ConfigurationData createMandatoryFieldConfiguration() {
    final ConfigurationData config = ValidatorTestData.createEmptyConfigurationWithDefaultGroup();
    final UiGroupData group = config.getGroups().get(0);

    final CsticData checkBoxListCstic = new CsticData();
    checkBoxListCstic.setRequired(true);
    checkBoxListCstic.setType(UiType.CHECK_BOX_LIST);
    final List<CsticValueData> domainvalues = new ArrayList<>();
    checkBoxListCstic.setDomainvalues(domainvalues);
    group.getCstics().add(checkBoxListCstic);

    final CsticData stringCstic = new CsticData();
    stringCstic.setType(UiType.STRING);
    stringCstic.setRequired(true);
    group.getCstics().add(stringCstic);

    final CsticData dropDownCstic = new CsticData();
    dropDownCstic.setRequired(true);
    dropDownCstic.setType(UiType.DROPDOWN);
    dropDownCstic.setDomainvalues(domainvalues);
    group.getCstics().add(dropDownCstic);
    return config;
  }