use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method issueSYNCOPE717.
@Test
public void issueSYNCOPE717() {
String doubleSchemaName = "double" + getUUIDString();
// 1. create double schema without conversion pattern
PlainSchemaTO schema = new PlainSchemaTO();
schema.setKey(doubleSchemaName);
schema.setType(AttrSchemaType.Double);
schema = createSchema(SchemaType.PLAIN, schema);
assertNotNull(schema);
assertNull(schema.getConversionPattern());
AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal group");
assertNotNull(minimalGroup);
minimalGroup.getPlainSchemas().add(doubleSchemaName);
anyTypeClassService.update(minimalGroup);
// 2. create group, provide valid input value
GroupTO groupTO = GroupITCase.getBasicSampleTO("syncope717");
groupTO.getPlainAttrs().add(attrTO(doubleSchemaName, "11.23"));
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 3. update schema, set conversion pattern
schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
schema.setConversionPattern("0.000");
schemaService.update(SchemaType.PLAIN, schema);
// 4. re-read group, verify that pattern was applied
groupTO = groupService.read(groupTO.getKey());
assertNotNull(groupTO);
assertEquals("11.230", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 5. modify group with new double value
GroupPatch patch = new GroupPatch();
patch.setKey(groupTO.getKey());
patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.257")).build());
groupTO = updateGroup(patch).getEntity();
assertNotNull(groupTO);
assertEquals("11.257", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 6. update schema, unset conversion pattern
schema.setConversionPattern(null);
schemaService.update(SchemaType.PLAIN, schema);
// 7. modify group with new double value, verify that no pattern is applied
patch = new GroupPatch();
patch.setKey(groupTO.getKey());
patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.23")).build());
groupTO = updateGroup(patch).getEntity();
assertNotNull(groupTO);
assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method deprovision.
@Test
public void deprovision() {
GroupTO groupTO = null;
try {
groupTO = createGroup(getSampleTO("deprovision")).getEntity();
assertNotNull(groupTO);
assertNotNull(groupTO.getKey());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(groupTO.getKey()).action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
groupTO = groupService.read(groupTO.getKey());
assertNotNull(groupTO);
assertFalse(groupTO.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
} finally {
if (groupTO != null) {
groupService.delete(groupTO.getKey());
}
}
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method update.
@Test
public void update() {
GroupTO groupTO = getSampleTO("latestGroup" + getUUIDString());
groupTO = createGroup(groupTO).getEntity();
assertEquals(1, groupTO.getPlainAttrs().size());
GroupPatch groupPatch = new GroupPatch();
groupPatch.setKey(groupTO.getKey());
String modName = "finalGroup" + getUUIDString();
groupPatch.setName(new StringReplacePatchItem.Builder().value(modName).build());
groupPatch.getPlainAttrs().add(attrAddReplacePatch("show", "FALSE"));
groupTO = updateGroup(groupPatch).getEntity();
assertEquals(modName, groupTO.getName());
assertEquals(2, groupTO.getPlainAttrs().size());
groupTO.getPlainAttr("show").get().getValues().clear();
groupTO = groupService.update(groupTO).readEntity(new GenericType<ProvisioningResult<GroupTO>>() {
}).getEntity();
assertFalse(groupTO.getPlainAttr("show").isPresent());
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method aStaticMembershipCount.
@Test
public void aStaticMembershipCount() {
// Create a new printer as a static member of a new group
GroupTO group = getBasicSampleTO("aStaticMembership");
group = createGroup(group).getEntity();
AnyObjectTO printer = new AnyObjectTO();
printer.setRealm(SyncopeConstants.ROOT_REALM);
printer.setName("Printer_" + getUUIDString());
printer.setType("PRINTER");
MembershipTO membership = new MembershipTO();
membership.setGroupKey(group.getKey());
printer.getMemberships().add(membership);
printer = createAnyObject(printer).getEntity();
group = groupService.read(group.getKey());
assertEquals(0, group.getDynamicAnyObjectMembershipCount());
assertEquals(1, group.getStaticAnyObjectMembershipCount());
anyObjectService.delete(printer.getKey());
groupService.delete(group.getKey());
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method deprovisionUnlinked.
@Test
public void deprovisionUnlinked() {
GroupTO groupTO = getSampleTO("deprovision");
groupTO.getResources().clear();
try {
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
try {
resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
groupTO = groupService.read(groupTO.getKey());
assertTrue(groupTO.getResources().isEmpty());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(groupTO.getKey()).action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
groupTO = groupService.read(groupTO.getKey());
assertNotNull(groupTO);
assertTrue(groupTO.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
} finally {
if (groupTO.getKey() != null) {
groupService.delete(groupTO.getKey());
}
}
}
Aggregations