use of org.apache.syncope.common.lib.to.AnyTypeClassTO 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.AnyTypeClassTO in project syncope by apache.
the class SAML2IdPMappingPanel method setAttrNames.
@Override
protected void setAttrNames(final AjaxTextFieldPanel toBeUpdated) {
toBeUpdated.setRequired(true);
toBeUpdated.setEnabled(true);
List<String> choices = new ArrayList<>(USER_FIELD_NAMES);
for (AnyTypeClassTO anyTypeClassTO : anyTypeClassRestClient.list(anyTypeRestClient.read(AnyTypeKind.USER.name()).getClasses())) {
choices.addAll(anyTypeClassTO.getPlainSchemas());
choices.addAll(anyTypeClassTO.getDerSchemas());
choices.addAll(anyTypeClassTO.getVirSchemas());
}
Collections.sort(choices);
toBeUpdated.setChoices(choices);
}
use of org.apache.syncope.common.lib.to.AnyTypeClassTO in project syncope by apache.
the class AnyTypeClassServiceImpl method create.
@Override
public Response create(final AnyTypeClassTO anyTypeTO) {
AnyTypeClassTO created = logic.create(anyTypeTO);
URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
return Response.created(location).header(RESTHeaders.RESOURCE_KEY, created.getKey()).build();
}
use of org.apache.syncope.common.lib.to.AnyTypeClassTO in project syncope by apache.
the class AnyTypeClassDataBinderImpl method getAnyTypeClassTO.
@Override
public AnyTypeClassTO getAnyTypeClassTO(final AnyTypeClass anyTypeClass) {
AnyTypeClassTO anyTypeClassTO = new AnyTypeClassTO();
anyTypeClassTO.setKey(anyTypeClass.getKey());
anyTypeClassTO.getInUseByTypes().addAll(anyTypeDAO.findByTypeClass(anyTypeClass).stream().map(Entity::getKey).collect(Collectors.toList()));
anyTypeClassTO.getPlainSchemas().addAll(anyTypeClass.getPlainSchemas().stream().map(Entity::getKey).collect(Collectors.toList()));
anyTypeClassTO.getDerSchemas().addAll(anyTypeClass.getDerSchemas().stream().map(Entity::getKey).collect(Collectors.toList()));
anyTypeClassTO.getVirSchemas().addAll(anyTypeClass.getVirSchemas().stream().map(Entity::getKey).collect(Collectors.toList()));
return anyTypeClassTO;
}
use of org.apache.syncope.common.lib.to.AnyTypeClassTO in project syncope by apache.
the class AnyTypeClassITCase method crud.
@Test
public void crud() {
// 1. create sample schemas
PlainSchemaTO plainSchema = new PlainSchemaTO();
plainSchema.setKey("new_plain_schema" + getUUIDString());
plainSchema.setType(AttrSchemaType.String);
plainSchema = createSchema(SchemaType.PLAIN, plainSchema);
DerSchemaTO derSchema = new DerSchemaTO();
derSchema.setKey("new_der_schema" + getUUIDString());
derSchema.setExpression(plainSchema.getKey() + " + '_' + derived_dx");
derSchema = createSchema(SchemaType.DERIVED, derSchema);
// 2. actual CRUD
AnyTypeClassTO newClass = new AnyTypeClassTO();
newClass.setKey("new class" + getUUIDString());
newClass.getPlainSchemas().add(plainSchema.getKey());
Response response = anyTypeClassService.create(newClass);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
newClass = getObject(response.getLocation(), AnyTypeClassService.class, AnyTypeClassTO.class);
assertNotNull(newClass);
assertFalse(newClass.getPlainSchemas().isEmpty());
assertTrue(newClass.getDerSchemas().isEmpty());
assertTrue(newClass.getVirSchemas().isEmpty());
newClass.getDerSchemas().add(derSchema.getKey());
anyTypeClassService.update(newClass);
newClass = anyTypeClassService.read(newClass.getKey());
assertNotNull(newClass);
assertFalse(newClass.getPlainSchemas().isEmpty());
assertFalse(newClass.getDerSchemas().isEmpty());
assertTrue(newClass.getVirSchemas().isEmpty());
assertEquals(newClass.getKey(), schemaService.read(SchemaType.PLAIN, plainSchema.getKey()).getAnyTypeClass());
assertEquals(newClass.getKey(), schemaService.read(SchemaType.DERIVED, derSchema.getKey()).getAnyTypeClass());
anyTypeClassService.delete(newClass.getKey());
try {
anyTypeClassService.read(newClass.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
assertNull(schemaService.read(SchemaType.PLAIN, plainSchema.getKey()).getAnyTypeClass());
assertNull(schemaService.read(SchemaType.DERIVED, derSchema.getKey()).getAnyTypeClass());
}
Aggregations