Java Code Examples for org.eclipse.microprofile.openapi.OASFactory#createObject()
The following examples show how to use
org.eclipse.microprofile.openapi.OASFactory#createObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OASFactoryResolverImplTest.java From smallrye-open-api with Apache License 2.0 | 5 votes |
/** * Test method for * {@link OASFactoryResolverImpl#createObject(java.lang.Class)}. */ @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testCreateObject_All() { Class modelClasses[] = { APIResponse.class, APIResponses.class, Callback.class, Components.class, Contact.class, Content.class, Discriminator.class, Encoding.class, Example.class, ExternalDocumentation.class, Header.class, Info.class, License.class, Link.class, MediaType.class, OAuthFlow.class, OAuthFlows.class, OpenAPI.class, Operation.class, Parameter.class, PathItem.class, Paths.class, RequestBody.class, Schema.class, SecurityRequirement.class, SecurityScheme.class, Server.class, ServerVariable.class, Tag.class, XML.class }; for (Class modelClass : modelClasses) { Constructible object = OASFactory.createObject(modelClass); Assert.assertNotNull(object); } }
Example 2
Source File: OASFactoryResolverImplTest.java From smallrye-open-api with Apache License 2.0 | 5 votes |
/** * Test method for * {@link OASFactoryResolverImpl#createObject(java.lang.Class)}. */ @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testCreateObject_RTE() { Class c = String.class; try { OASFactory.createObject(c); Assert.fail("Expected a runtime error."); } catch (RuntimeException e) { Assert.assertEquals("SROAP09000: Class 'java.lang.String' is not Constructible.", e.getMessage()); } }
Example 3
Source File: ModelConstructionTest.java From microprofile-open-api with Apache License 2.0 | 5 votes |
private <T extends Constructible> T createConstructibleInstance(Class<T> clazz) { // Check that the OASFactory is able to create an instance of the given Class. final T o1 = OASFactory.createObject(clazz); assertNotNull(o1, "The return value of OASFactory.createObject(" + clazz.getName() + ") must not be null."); assertTrue(clazz.isInstance(o1), "The return value of OASFactory.createObject() is expected to be an instance of: " + clazz.getName()); final T o2 = OASFactory.createObject(clazz); assertNotNull(o2, "The return value of OASFactory.createObject(" + clazz.getName() + ") must not be null."); assertTrue(clazz.isInstance(o2), "The return value of OASFactory.createObject() is expected to be an instance of: " + clazz.getName()); assertNotSame(o2, o1, "OASFactory.createObject(" + clazz.getName() + ") is expected to create a new object on each invocation."); return o1; }
Example 4
Source File: HelloModelReader.java From microprofile1.4-samples with MIT License | 4 votes |
@Override public OpenAPI buildModel() { return OASFactory.createObject(OpenAPI.class); }
Example 5
Source File: OASFactoryErrorTest.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = { NullPointerException.class }) public void nullValueTest() { @SuppressWarnings("unused") final Object o = OASFactory.createObject(null); }
Example 6
Source File: OASFactoryErrorTest.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = { IllegalArgumentException.class }) public void baseInterfaceTest() { @SuppressWarnings("unused") final Constructible c = OASFactory.createObject(Constructible.class); }
Example 7
Source File: OASFactoryErrorTest.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = { IllegalArgumentException.class }) public void extendedBaseInterfaceTest() { @SuppressWarnings("unused") final MyConstructible m = OASFactory.createObject(MyConstructible.class); }
Example 8
Source File: OASFactoryErrorTest.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = { IllegalArgumentException.class }) public void extendedInterfaceTest() { @SuppressWarnings("unused") final MyLicense m = OASFactory.createObject(MyLicense.class); }
Example 9
Source File: OASFactoryErrorTest.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = { IllegalArgumentException.class }) public void customAbstractClassTest() { @SuppressWarnings("unused") final MyAbstractLicenseImpl m = OASFactory.createObject(MyAbstractLicenseImpl.class); }
Example 10
Source File: OASFactoryErrorTest.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = { IllegalArgumentException.class }) public void customClassTest() { @SuppressWarnings("unused") final MyLicenseImpl m = OASFactory.createObject(MyLicenseImpl.class); }