use of com.reprezen.kaizen.oasparser.model3.Schema in project policies-ui-backend by RedHatInsights.
the class OapiTest method validateOpenApi.
@Test
void validateOpenApi() throws Exception {
OpenApi3 model = new OpenApi3Parser().parse(url, true);
System.out.printf("OpenAPI Model at %s\n", url);
if (!model.isValid()) {
for (ValidationResults.ValidationItem item : model.getValidationItems()) {
System.err.println(item);
}
fail("OpenAPI spec is not valid");
}
//
// Now that basic validation is done, we can add some of our own
//
Map<String, Path> paths = model.getPaths();
Map<String, Schema> schemas = model.getSchemas();
// The base path filler. See also OASModifier.mangleName
assertTrue(paths.containsKey("/"));
// User config is private, so don't show it
assertFalse(paths.containsKey("/user-config"));
assertFalse(schemas.containsKey("SettingsValues"));
// Check that openapi does not (again) collapse parameters
assertEquals(9, paths.get("/policies").getOperation("get").getParameters().size());
// Check that all properties are present ( https://github.com/smallrye/smallrye-open-api/issues/437 )
Map<String, Schema> policyProperties = schemas.get("Policy").getProperties();
assertEquals(9, policyProperties.size());
assertTrue(policyProperties.containsKey("ctime"));
assertTrue(policyProperties.containsKey("mtime"));
// Now that the OpenAPI file has been validated, save a copy to the filesystem
// This file is going to be uploaded in a regular CI build to know the API state
// for a given build.
InputStream in = url.openStream();
Files.copy(in, Paths.get(TARGET_OPENAPI), StandardCopyOption.REPLACE_EXISTING);
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method listSchemasTest2.
@Test
public void listSchemasTest2() throws Exception {
Schema responsesElement = Schema.newBuilder().build();
ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
mockSchemaService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method validateSchemaTest2.
@Test
public void validateSchemaTest2() throws Exception {
ValidateSchemaResponse expectedResponse = ValidateSchemaResponse.newBuilder().build();
mockSchemaService.addResponse(expectedResponse);
String parent = "parent-995424086";
Schema schema = Schema.newBuilder().build();
ValidateSchemaResponse actualResponse = client.validateSchema(parent, schema);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ValidateSchemaRequest actualRequest = ((ValidateSchemaRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertEquals(schema, actualRequest.getSchema());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method createSchemaTest2.
@Test
public void createSchemaTest2() throws Exception {
Schema expectedResponse = Schema.newBuilder().setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()).setDefinition("definition-1014418093").build();
mockSchemaService.addResponse(expectedResponse);
String parent = "parent-995424086";
Schema schema = Schema.newBuilder().build();
String schemaId = "schemaId-697673060";
Schema actualResponse = client.createSchema(parent, schema, schemaId);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSchemaRequest actualRequest = ((CreateSchemaRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertEquals(schema, actualRequest.getSchema());
Assert.assertEquals(schemaId, actualRequest.getSchemaId());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method listSchemasTest.
@Test
public void listSchemasTest() throws Exception {
Schema responsesElement = Schema.newBuilder().build();
ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
mockSchemaService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations