This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 6103c8a Fixed CS for Camel-Olingo4 6103c8a is described below commit 6103c8a86948ca61f5ae0294510ab6f86e973ca2 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Wed Jan 30 08:34:38 2019 +0100 Fixed CS for Camel-Olingo4 --- .../camel/component/olingo4/Olingo4Index.java | 26 ++++---- .../component/olingo4/Olingo4ComponentTest.java | 75 +++++++++------------- 2 files changed, 43 insertions(+), 58 deletions(-) diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Index.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Index.java index a5f7694..46c4343 100644 --- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Index.java +++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Index.java @@ -1,11 +1,12 @@ -/* - * Copyright (C) 2016 Red Hat, Inc. +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -20,6 +21,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; + import org.apache.olingo.client.api.domain.ClientEntity; import org.apache.olingo.client.api.domain.ClientEntitySet; @@ -86,20 +88,20 @@ public class Olingo4Index { */ public void index(Object result) { if (result instanceof ClientEntitySet) { - index((ClientEntitySet) result); + index((ClientEntitySet)result); } else if (result instanceof Iterable) { - index((Iterable<?>) result); + index((Iterable<?>)result); } else { indexDefault(result); } } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Object filterResponse(Object response) { if (response instanceof ClientEntitySet) { - response = filter((ClientEntitySet) response); + response = filter((ClientEntitySet)response); } else if (response instanceof Iterable) { - response = filter((Iterable<Object>) response); + response = filter((Iterable<Object>)response); } else if (response.getClass().isArray()) { List<Object> result = new ArrayList<>(); final int size = Array.getLength(response); diff --git a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java index fd34bdb..717ee74 100644 --- a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java +++ b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.camel.CamelExecutionException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; @@ -60,17 +61,9 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { private static final String TEST_CREATE_PEOPLE = PEOPLE + "(" + TEST_CREATE_KEY + ")"; private static final String TEST_CREATE_RESOURCE_CONTENT_ID = "1"; private static final String TEST_UPDATE_RESOURCE_CONTENT_ID = "2"; - private static final String TEST_CREATE_JSON = "{\n" - + " \"UserName\": \"lewisblack\",\n" - + " \"FirstName\": \"Lewis\",\n" - + " \"LastName\": \"Black\"\n" - + "}"; - private static final String TEST_UPDATE_JSON = "{\n" - + " \"UserName\": \"lewisblack\",\n" - + " \"FirstName\": \"Lewis\",\n" - + " \"MiddleName\": \"Black\",\n" - + " \"LastName\": \"Black\"\n" - + "}"; + private static final String TEST_CREATE_JSON = "{\n" + " \"UserName\": \"lewisblack\",\n" + " \"FirstName\": \"Lewis\",\n" + " \"LastName\": \"Black\"\n" + "}"; + private static final String TEST_UPDATE_JSON = "{\n" + " \"UserName\": \"lewisblack\",\n" + " \"FirstName\": \"Lewis\",\n" + " \"MiddleName\": \"Black\",\n" + + " \"LastName\": \"Black\"\n" + "}"; @Test public void testRead() throws Exception { @@ -116,12 +109,12 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { final ClientEntity unbFuncReturn = (ClientEntity)requestBodyAndHeaders("direct:callunboundfunction", null, headers); assertNotNull(unbFuncReturn); } - + @Test public void testReadWithFilter() { // Read entity set with filter of the Airports object final ClientEntitySet entities = (ClientEntitySet)requestBody("direct:readwithfilter", null); - + assertNotNull(entities); assertEquals(1, entities.getEntities().size()); } @@ -269,25 +262,25 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { assertNotNull(error); LOG.info("Read deleted entity error: {}", error.getMessage()); } - + @SuppressWarnings("unchecked") @Test public void testEndpointHttpHeaders() throws Exception { final Map<String, Object> headers = new HashMap<>(); final ClientEntity entity = (ClientEntity)requestBodyAndHeaders("direct:read-etag", null, headers); - + MockEndpoint mockEndpoint = getMockEndpoint("mock:check-etag-header"); mockEndpoint.expectedMessageCount(1); mockEndpoint.assertIsSatisfied(); - + Map<String, String> responseHttpHeaders = (Map<String, String>)mockEndpoint.getExchanges().get(0).getIn().getHeader("CamelOlingo4.responseHttpHeaders"); assertEquals(responseHttpHeaders.get("ETag"), entity.getETag()); - + Map<String, String> endpointHttpHeaders = new HashMap<>(); endpointHttpHeaders.put("If-Match", entity.getETag()); headers.put("CamelOlingo4.endpointHttpHeaders", endpointHttpHeaders); requestBodyAndHeaders("direct:delete-with-etag", null, headers); - + // check for deleted entity with ETag try { requestBody("direct:read-etag", null); @@ -297,10 +290,9 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { } /** - * Read entity set of the People object - * and filter already seen items on subsequent exchanges - * Use a delay since the mock endpoint does not always get - * the correct number of exchanges before being satisfied. + * Read entity set of the People object and filter already seen items on + * subsequent exchanges Use a delay since the mock endpoint does not always + * get the correct number of exchanges before being satisfied. */ @Test public void testConsumerReadFilterAlreadySeen() throws Exception { @@ -324,10 +316,9 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { // First polled messages contained all the entities // assertTrue(body instanceof ClientEntitySet); - ClientEntitySet set = (ClientEntitySet) body; + ClientEntitySet set = (ClientEntitySet)body; assertEquals(expectedEntities, set.getEntities().size()); - } - else { + } else { // // Subsequent polling messages should be empty // since the filterAlreadySeen property is true @@ -338,10 +329,8 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { } /** - * - * Read entity set of the People object - * and with no filter already seen, all items - * should be present in each message + * Read entity set of the People object and with no filter already seen, all + * items should be present in each message * * @throws Exception */ @@ -364,7 +353,7 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { for (int i = 0; i < expectedMsgCount; ++i) { Object body = mockEndpoint.getExchanges().get(i).getIn().getBody(); assertTrue(body instanceof ClientEntitySet); - ClientEntitySet set = (ClientEntitySet) body; + ClientEntitySet set = (ClientEntitySet)body; // // All messages contained all the entities @@ -374,8 +363,8 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { } /** - * Read entity set of the People object - * and filter already seen items on subsequent exchanges + * Read entity set of the People object and filter already seen items on + * subsequent exchanges */ @Test public void testProducerReadFilterAlreadySeen() throws Exception { @@ -396,15 +385,14 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { for (int i = 0; i < expectedMsgCount; ++i) { Object body = mockEndpoint.getExchanges().get(i).getIn().getBody(); assertTrue(body instanceof ClientEntitySet); - ClientEntitySet set = (ClientEntitySet) body; + ClientEntitySet set = (ClientEntitySet)body; if (i == 0) { // // First polled messages contained all the entities // assertEquals(expectedEntities, set.getEntities().size()); - } - else { + } else { // // Subsequent messages should be empty // since the filterAlreadySeen property is true @@ -434,7 +422,7 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { from("direct:readcomplexprop").to("olingo4://read/Airports('KSFO')/Location"); from("direct:readentitybyid").to("olingo4://read/People('russellwhyte')"); - + from("direct:readwithfilter").to("olingo4://read/Airports?$filter=Name eq 'San Francisco International Airport'"); from("direct:callunboundfunction").to("olingo4://read/GetNearestAirport(lat=33,lon=-118)"); @@ -453,24 +441,19 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport { // test route for batch from("direct:batch").to("olingo4://batch"); - + from("direct:read-etag").to("olingo4://read/Airlines('AA')").to("mock:check-etag-header"); - + from("direct:delete-with-etag").to("olingo4://delete/Airlines('AA')"); - from("direct:read-people-nofilterseen") - .to("olingo4://read/People") - .to("mock:producer-noalreadyseen"); + from("direct:read-people-nofilterseen").to("olingo4://read/People").to("mock:producer-noalreadyseen"); - from("direct:read-people-filterseen") - .to("olingo4://read/People?filterAlreadySeen=true") - .to("mock:producer-alreadyseen"); + from("direct:read-people-filterseen").to("olingo4://read/People?filterAlreadySeen=true").to("mock:producer-alreadyseen"); // // Consumer endpoint // - from("olingo4://read/People?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true") - .to("mock:consumer-alreadyseen"); + from("olingo4://read/People?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true").to("mock:consumer-alreadyseen"); } }; }