Showing paste #u0z89 by ilgrosso@apache.org: (Show raw paste)
@Test
public void issueSYNCOPE1543() {
// 1. create group with no type extensions
GroupTO groupTO = getSampleTO("syncope1543");
groupTO.getPlainAttrs().add(attrTO("icon", "anIcon"));
groupTO.getPlainAttrs().add(attrTO("show", "true"));
groupTO.getResources().clear();
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
assertEquals(0, groupTO.getTypeExtensions().size());
// 2. update group, add type extension for USER
GroupPatch groupPatch = new GroupPatch();
groupPatch.setKey(groupTO.getKey());
TypeExtensionTO typeExtension = new TypeExtensionTO();
typeExtension.setAnyType(AnyTypeKind.USER.name());
typeExtension.getAuxClasses().add("csv");
groupPatch.getTypeExtensions().add(typeExtension);
groupTO = updateGroup(groupPatch).getEntity();
assertEquals(1, groupTO.getTypeExtensions().size());
assertEquals(
Collections.singletonList("csv"),
groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses());
// 3. update group's attribute
groupPatch = new GroupPatch();
groupPatch.setKey(groupTO.getKey());
groupPatch.getPlainAttrs().add(attrAddReplacePatch("icon", "anIconUpdate"));
groupPatch.getTypeExtensions().addAll(groupTO.getTypeExtensions());
groupTO = updateGroup(groupPatch).getEntity();
assertEquals("anIconUpdate", groupTO.getPlainAttr("icon").get().getValues().get(0));
assertEquals(1, groupTO.getTypeExtensions().size());
// 4. delete group
GroupTO deletedGroup = deleteGroup(groupTO.getKey()).getEntity();
assertNotNull(deletedGroup);
try {
groupService.read(deletedGroup.getKey());
fail();
} catch (SyncopeClientException e) {
assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
}
}
Make a new paste