use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType in project midpoint by Evolveum.
the class TestSchemaRestService method test010listSchemas.
@Test
public void test010listSchemas() {
WebClient client = prepareClient();
when();
Response response = client.get();
then();
assertStatus(response, 200);
SchemaFilesType schemas = response.readEntity(SchemaFilesType.class);
assertNotNull("Error response must contain list of schemas", schemas);
logger.info("Returned result: {}", schemas);
assertAndGetPiracySchemaFile(schemas);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType in project midpoint by Evolveum.
the class TestSchemaRestService method assertAndGetPiracySchemaFile.
private SchemaFileType assertAndGetPiracySchemaFile(SchemaFilesType schemas) {
assertNotNull("Schema file list must no be null", schemas);
assertEquals(1, schemas.getSchema().size());
SchemaFileType schemaFile = schemas.getSchema().get(0);
assertEquals("piracy.xsd", schemaFile.getFileName());
assertEquals("http://midpoint.evolveum.com/xml/ns/samples/piracy", schemaFile.getNamespace());
assertEquals(null, schemaFile.getUsualPrefix());
return schemaFile;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType in project midpoint by Evolveum.
the class TestSchemaRestService method test020getSchema.
@Test
public void test020getSchema() throws IOException {
WebClient client = prepareClient();
when();
Response response = client.get();
SchemaFilesType schemas = response.readEntity(SchemaFilesType.class);
SchemaFileType file = assertAndGetPiracySchemaFile(schemas);
client.path("/" + file.getFileName());
client.accept(MediaType.TEXT_PLAIN_TYPE);
response = client.get();
then();
assertStatus(response, 200);
String content = response.readEntity(String.class);
String expected = FileUtils.readFileToString(new File("./src/test/resources/schema/piracy.xsd"), StandardCharsets.UTF_8);
assertEquals("Schemas doesn't match", expected, content);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType in project midpoint by Evolveum.
the class ExtensionSchemaRestController method listSchemas.
@GetMapping
public ResponseEntity<?> listSchemas() {
Task task = initRequest();
OperationResult result = createSubresult(task, "listSchemas");
ResponseEntity<?> response;
try {
securityEnforcer.authorize(ModelAuthorizationAction.GET_EXTENSION_SCHEMA.getUrl(), null, AuthorizationParameters.EMPTY, null, task, result);
SchemaRegistry registry = prismContext.getSchemaRegistry();
Collection<SchemaDescription> descriptions = registry.getSchemaDescriptions();
SchemaFilesType files = new SchemaFilesType();
for (SchemaDescription description : descriptions) {
String name = computeName(description);
if (name == null) {
continue;
}
files.schema(new SchemaFileType().namespace(description.getNamespace()).usualPrefix(description.getUsualPrefix()).fileName(name));
}
response = ResponseEntity.ok(files);
} catch (Exception ex) {
result.recordFatalError(ex);
response = handleException(result, ex);
}
finishRequest(task, result);
return response;
}
Aggregations