assertEquals(_group1_Name1_SchematronId1.getId(), saved.getGroup().getId());
}
@Test
public void testAddToNewGroup() throws Exception {
ServiceContext context = createServiceContext();
loginAsAdmin(context);
final String uitype = "uitype";
final String uivalue = "uivalue";
final String value = "x/y/z";
final SchematronCriteriaType criteriaType = SchematronCriteriaType.XPATH;
String newName = "newGroupName" + _inc.incrementAndGet();
final int schematronId = _group1_Name1_SchematronId1.getId().getSchematronId();
Element params = createParams(
read(SchematronCriteriaService.PARAM_GROUP_NAME, newName),
read(SchematronCriteriaService.PARAM_SCHEMATRON_ID, schematronId),
read(SchematronCriteriaService.PARAM_TYPE, criteriaType),
read(SchematronCriteriaService.PARAM_VALUE, value),
read(SchematronCriteriaService.PARAM_UI_TYPE, uitype),
read(SchematronCriteriaService.PARAM_UI_VALUE, uivalue)
);
assertFalse(context.getBean(SchematronCriteriaGroupRepository.class).exists(new SchematronCriteriaGroupId(newName,
schematronId)));
Element result = createService(ADD).exec(params, context);
assertSuccessfulAdd(result);
String id = result.getChildText("id");
final SchematronCriteriaGroup found = context.getBean(SchematronCriteriaGroupRepository.class).findOne(new
SchematronCriteriaGroupId(newName, schematronId));
assertTrue(found != null);
assertEquals(SchematronRequirement.REQUIRED, found.getRequirement());
params = createParams(
read(Params.ID, id)
);
result = createService(EXISTS).exec(params, context);
assertEquals(Boolean.TRUE.toString(), result.getText());
final SchematronCriteria saved = context.getBean(SchematronCriteriaRepository.class).findOne(Integer.parseInt(id));
assertEquals(value, saved.getValue());
assertEquals(criteriaType, saved.getType());
assertEquals(uivalue, saved.getUiValue());
assertEquals(uitype, saved.getUiType());