org.apache.johnzon.mapper.reflection.JohnzonParameterizedType Java Examples
The following examples show how to use
org.apache.johnzon.mapper.reflection.JohnzonParameterizedType.
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: DefaultValueInspectorTest.java From component-runtime with Apache License 2.0 | 6 votes |
@Test void createListInstance() { final DefaultValueInspector inspector = new DefaultValueInspector(); final DefaultValueInspector.Instance demoInstance = inspector .createDemoInstance(new Wrapper(), new ParameterMeta(null, new JohnzonParameterizedType(List.class, Foo.class), ARRAY, "foos", "foos", null, singletonList(new ParameterMeta(null, Foo.class, OBJECT, "foos[${index}]", "foos[${index}]", null, singletonList(new ParameterMeta(null, Foo.class, STRING, "foos[${index}].name", "name", null, emptyList(), null, emptyMap(), false)), null, emptyMap(), false)), null, emptyMap(), false)); assertNotNull(demoInstance.getValue()); assertTrue(demoInstance.isCreated()); assertTrue(Collection.class.isInstance(demoInstance.getValue())); final Collection<?> list = Collection.class.cast(demoInstance.getValue()); assertEquals(1, list.size()); final Object first = list.iterator().next(); assertNotNull(first); assertTrue(Foo.class.isInstance(first)); assertNull(Foo.class.cast(first).name); }
Example #2
Source File: MultipartTest.java From openwebbeans-meecrowave with Apache License 2.0 | 6 votes |
@Test public void configBinding() { try (final Meecrowave meecrowave = new Meecrowave( new Meecrowave.Builder() .randomHttpPort() .includePackages(MultipartTest.MultiEndpoint.class.getName())).bake()) { final Client client = ClientBuilder.newClient(); try { // for mixed types use org.apache.cxf.jaxrs.ext.multipart.MultipartBody final Map<String, JsonbModel> response = client.target("http://localhost:" + meecrowave.getConfiguration().getHttpPort() + "/MultipartTest") .request() .get(new GenericType<Map<String, JsonbModel>>(new JohnzonParameterizedType(Map.class, String.class, JsonbModel.class)) {{}}); assertEquals(1, response.size()); assertEquals("ok", response.get(MediaType.APPLICATION_JSON).value); } finally { client.close(); } } }
Example #3
Source File: JsonDataformatsRoute.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Override public void configure() { JacksonDataFormat jacksonDummyObjectDataFormat = new JacksonDataFormat(DummyObject.class); jacksonDummyObjectDataFormat.useList(); ObjectMapper jacksonObjectMapper = new ObjectMapper(); jacksonObjectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); jacksonDummyObjectDataFormat.setObjectMapper(jacksonObjectMapper); configureJsonRoutes(JsonLibrary.Jackson, jacksonDummyObjectDataFormat, new JacksonDataFormat(PojoA.class), new JacksonDataFormat(PojoB.class)); JohnzonDataFormat johnzonDummyObjectDataFormat = new JohnzonDataFormat(); johnzonDummyObjectDataFormat.setParameterizedType(new JohnzonParameterizedType(List.class, DummyObject.class)); configureJsonRoutes(JsonLibrary.Johnzon, johnzonDummyObjectDataFormat, new JohnzonDataFormat(PojoA.class), new JohnzonDataFormat(PojoB.class)); GsonDataFormat gsonDummyObjectDataFormat = new GsonDataFormat(); Type genericType = new TypeToken<List<DummyObject>>() { }.getType(); gsonDummyObjectDataFormat.setUnmarshalGenericType(genericType); gsonDummyObjectDataFormat.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES); gsonDummyObjectDataFormat.setExclusionStrategies(Arrays.<ExclusionStrategy> asList(new ExclusionStrategy() { @Override public boolean shouldSkipField(FieldAttributes f) { return f.getAnnotation(ExcludeField.class) != null; } @Override public boolean shouldSkipClass(Class<?> clazz) { return false; } })); configureJsonRoutes(JsonLibrary.Gson, gsonDummyObjectDataFormat, new GsonDataFormat(PojoA.class), new GsonDataFormat(PojoB.class)); from("direct:jacksonxml-marshal") .marshal() .jacksonxml(true); from("direct:jacksonxml-unmarshal") .unmarshal() .jacksonxml(PojoA.class); }