You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/01/30 07:30:27 UTC

[camel] branch master updated: Fixed CS for Camel-Olingo 2

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 5934b1e  Fixed CS for Camel-Olingo 2
5934b1e is described below

commit 5934b1ecfc1de426bc1a7b5ef1d7a08931143e73
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 30 08:30:06 2019 +0100

    Fixed CS for Camel-Olingo 2
---
 .../camel/component/olingo2/Olingo2Index.java      |  36 +++----
 .../component/olingo2/Olingo2ComponentTest.java    | 109 +++++++++------------
 2 files changed, 63 insertions(+), 82 deletions(-)

diff --git a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Index.java b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Index.java
index 81ac6a2..0feb7bb 100644
--- a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Index.java
+++ b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Index.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.odata2.api.ep.entry.EntryMetadata;
 import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
 import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
@@ -44,8 +46,8 @@ public class Olingo2Index {
     }
 
     /**
-     * Hash entry leaving out certain fields that change
-     * between exchange messages
+     * Hash entry leaving out certain fields that change between exchange
+     * messages
      *
      * @param entry
      * @return hascode of entry
@@ -57,7 +59,8 @@ public class Olingo2Index {
         result = prime * result + ((entry.getMetadata() == null) ? 0 : hash(entry.getMetadata()));
         result = prime * result + ((entry.getProperties() == null) ? 0 : entry.getProperties().hashCode());
 
-        // Ignore mediaMetadata, expandSelectTree since its object changes each time
+        // Ignore mediaMetadata, expandSelectTree since its object changes each
+        // time
 
         return result;
     }
@@ -120,21 +123,20 @@ public class Olingo2Index {
      */
     public void index(Object result) {
         if (result instanceof ODataFeed) {
-            index((ODataFeed) result);
+            index((ODataFeed)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 ODataFeed) {
-            response = filter((ODataFeed) response);
-        } else
-        if (response instanceof Iterable) {
-            response = filter((Iterable<Object>) response);
+            response = filter((ODataFeed)response);
+        } else if (response instanceof Iterable) {
+            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-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java
index 3512108..0e6007e 100644
--- a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java
+++ b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java
@@ -15,11 +15,13 @@
  * limitations under the License.
  */
 package org.apache.camel.component.olingo2;
+
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.component.olingo2.api.batch.Olingo2BatchChangeRequest;
@@ -43,16 +45,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Test class for {@link org.apache.camel.component.olingo2.api.Olingo2App} APIs.
+ * Test class for {@link org.apache.camel.component.olingo2.api.Olingo2App}
+ * APIs.
  * <p>
- * The integration test runs against Apache Olingo 2.0 sample server
- * which is dynamically installed and started during the test.
+ * The integration test runs against Apache Olingo 2.0 sample server which is
+ * dynamically installed and started during the test.
  * </p>
  */
 public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
 
     private static final Logger LOG = LoggerFactory.getLogger(Olingo2ComponentTest.class);
-    private static final int PORT = AvailablePortFinder.getNextAvailable();  
+    private static final int PORT = AvailablePortFinder.getNextAvailable();
     private static final String ID_PROPERTY = "Id";
     private static final String MANUFACTURERS = "Manufacturers";
     private static final String TEST_MANUFACTURER = "Manufacturers('1')";
@@ -183,20 +186,17 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
 
         // 5. create
         final Map<String, Object> data = getEntityData();
-        batchParts.add(Olingo2BatchChangeRequest.resourcePath(MANUFACTURERS).
-            contentId(TEST_RESOURCE_CONTENT_ID).operation(Operation.CREATE).body(data).build());
+        batchParts.add(Olingo2BatchChangeRequest.resourcePath(MANUFACTURERS).contentId(TEST_RESOURCE_CONTENT_ID).operation(Operation.CREATE).body(data).build());
 
         // 6. update address in created entry
         final Map<String, Object> updateData = new HashMap<>(data);
-        Map<String, Object> address = (Map<String, Object>) updateData.get(ADDRESS);
+        Map<String, Object> address = (Map<String, Object>)updateData.get(ADDRESS);
         address.put("Street", "Main Street");
-        batchParts.add(
-            Olingo2BatchChangeRequest.resourcePath(TEST_RESOURCE_ADDRESS).operation(Operation.UPDATE).body(address).build());
+        batchParts.add(Olingo2BatchChangeRequest.resourcePath(TEST_RESOURCE_ADDRESS).operation(Operation.UPDATE).body(address).build());
 
         // 7. update
         updateData.put("Name", "MyCarManufacturer Renamed");
-        batchParts.add(Olingo2BatchChangeRequest.resourcePath(TEST_RESOURCE).operation(Operation.UPDATE)
-            .body(updateData).build());
+        batchParts.add(Olingo2BatchChangeRequest.resourcePath(TEST_RESOURCE).operation(Operation.UPDATE).body(updateData).build());
 
         // 8. delete
         batchParts.add(Olingo2BatchChangeRequest.resourcePath(TEST_RESOURCE).operation(Operation.DELETE).build());
@@ -209,23 +209,23 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
         assertNotNull("Batch response", responseParts);
         assertEquals("Batch responses expected", 9, responseParts.size());
 
-        final Edm edm = (Edm) responseParts.get(0).getBody();
+        final Edm edm = (Edm)responseParts.get(0).getBody();
         assertNotNull(edm);
         LOG.info("Edm entity sets: {}", edm.getEntitySets());
 
-        final ODataFeed feed = (ODataFeed) responseParts.get(1).getBody();
+        final ODataFeed feed = (ODataFeed)responseParts.get(1).getBody();
         assertNotNull(feed);
         LOG.info("Read feed: {}", feed.getEntries());
 
-        ODataEntry dataEntry = (ODataEntry) responseParts.get(2).getBody();
+        ODataEntry dataEntry = (ODataEntry)responseParts.get(2).getBody();
         assertNotNull(dataEntry);
         LOG.info("Read entry: {}", dataEntry.getProperties());
 
-        dataEntry = (ODataEntry) responseParts.get(3).getBody();
+        dataEntry = (ODataEntry)responseParts.get(3).getBody();
         assertNotNull(dataEntry);
         LOG.info("Read entry with $expand: {}", dataEntry.getProperties());
 
-        dataEntry = (ODataEntry) responseParts.get(4).getBody();
+        dataEntry = (ODataEntry)responseParts.get(4).getBody();
         assertNotNull(dataEntry);
         LOG.info("Created entry: {}", dataEntry.getProperties());
 
@@ -242,16 +242,15 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
         LOG.info("Delete status: {}", statusCode);
 
         assertEquals(HttpStatusCodes.NOT_FOUND.getStatusCode(), responseParts.get(8).getStatusCode());
-        final Exception exception = (Exception) responseParts.get(8).getBody();
+        final Exception exception = (Exception)responseParts.get(8).getBody();
         assertNotNull(exception);
         LOG.info("Read deleted entry exception: {}", exception);
     }
 
     /**
-     * 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 {
@@ -275,10 +274,9 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
                 // First polled messages contained all the manufacturers
                 //
                 assertTrue(body instanceof ODataFeed);
-                ODataFeed set = (ODataFeed) body;
+                ODataFeed set = (ODataFeed)body;
                 assertEquals(expectedManufacturers, set.getEntries().size());
-            }
-            else {
+            } else {
                 //
                 // Subsequent polling messages should be empty
                 // since the filterAlreadySeen property is true
@@ -289,10 +287,8 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
     }
 
     /**
-     *
-     * 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
      */
@@ -318,7 +314,7 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
         for (int i = 0; i < expectedMsgCount; ++i) {
             Object body = mockEndpoint.getExchanges().get(i).getIn().getBody();
             assertTrue(body instanceof ODataFeed);
-            ODataFeed set = (ODataFeed) body;
+            ODataFeed set = (ODataFeed)body;
 
             //
             // All messages contained all the manufacturers
@@ -328,8 +324,8 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
     }
 
     /**
-     * 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 {
@@ -353,15 +349,14 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
         for (int i = 0; i < expectedMsgCount; ++i) {
             Object body = mockEndpoint.getExchanges().get(i).getIn().getBody();
             assertTrue(body instanceof ODataFeed);
-            ODataFeed set = (ODataFeed) body;
+            ODataFeed set = (ODataFeed)body;
 
             if (i == 0) {
                 //
                 // First polled messages contained all the manufacturers
                 //
                 assertEquals(expectedEntities, set.getEntries().size());
-            }
-            else {
+            } else {
                 //
                 // Subsequent messages should be empty
                 // since the filterAlreadySeen property is true
@@ -376,54 +371,38 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
         return new RouteBuilder() {
             public void configure() {
                 // test routes for read
-                from("direct:READSERVICEDOC")
-                    .to("olingo2://read/");
+                from("direct:READSERVICEDOC").to("olingo2://read/");
 
-                from("direct:READFEED")
-                    .to("olingo2://read/Manufacturers?$orderBy=Name%20asc");
+                from("direct:READFEED").to("olingo2://read/Manufacturers?$orderBy=Name%20asc");
 
-                from("direct:READENTRY")
-                    .to("olingo2://read/DefaultContainer.Manufacturers");
+                from("direct:READENTRY").to("olingo2://read/DefaultContainer.Manufacturers");
 
                 // test route for create
-                from("direct:CREATE")
-                    .to("olingo2://create/Manufacturers");
+                from("direct:CREATE").to("olingo2://create/Manufacturers");
 
                 // test route for update
-                from("direct:UPDATE")
-                    .to("olingo2://update/Manufacturers('123')");
+                from("direct:UPDATE").to("olingo2://update/Manufacturers('123')");
 
                 // test route for delete
-                from("direct:DELETE")
-                    .to("olingo2://delete/Manufacturers('123')");
-
-/*
-                // test route for merge
-                from("direct:MERGE")
-                    .to("olingo2://merge");
+                from("direct:DELETE").to("olingo2://delete/Manufacturers('123')");
 
-                // test route for patch
-                from("direct:PATCH")
-                    .to("olingo2://patch");
-*/
+                /*
+                 * // test route for merge from("direct:MERGE")
+                 * .to("olingo2://merge"); // test route for patch
+                 * from("direct:PATCH") .to("olingo2://patch");
+                 */
 
                 // test route for batch
-                from("direct:BATCH")
-                    .to("olingo2://batch");
+                from("direct:BATCH").to("olingo2://batch");
 
-                from("direct:read-people-nofilterseen")
-                    .to("olingo2://read/Manufacturers")
-                    .to("mock:producer-noalreadyseen");
+                from("direct:read-people-nofilterseen").to("olingo2://read/Manufacturers").to("mock:producer-noalreadyseen");
 
-                from("direct:read-people-filterseen")
-                    .to("olingo2://read/Manufacturers?filterAlreadySeen=true")
-                    .to("mock:producer-alreadyseen");
+                from("direct:read-people-filterseen").to("olingo2://read/Manufacturers?filterAlreadySeen=true").to("mock:producer-alreadyseen");
 
                 //
                 // Consumer endpoint
                 //
-                from("olingo2://read/Manufacturers?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true")
-                    .to("mock:consumer-alreadyseen");
+                from("olingo2://read/Manufacturers?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true").to("mock:consumer-alreadyseen");
             }
         };
     }