You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/08/04 16:10:02 UTC
[11/19] camel git commit: CAMEL-11555: ServiceNow : create a maven
plugin to generate models based on table layout
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowServiceCatalogProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowServiceCatalogProcessor.java b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowServiceCatalogProcessor.java
deleted file mode 100644
index 42b5da3..0000000
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowServiceCatalogProcessor.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.camel.component.servicenow.releases.helsinki;
-
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.component.servicenow.AbstractServiceNowProcessor;
-import org.apache.camel.component.servicenow.ServiceNowEndpoint;
-import org.apache.camel.component.servicenow.ServiceNowParams;
-import org.apache.camel.util.ObjectHelper;
-
-import static org.apache.camel.component.servicenow.ServiceNowConstants.ACTION_RETRIEVE;
-import static org.apache.camel.component.servicenow.ServiceNowConstants.ACTION_SUBJECT_CATEGORIES;
-
-class HelsinkiServiceNowServiceCatalogProcessor extends AbstractServiceNowProcessor {
-
- HelsinkiServiceNowServiceCatalogProcessor(ServiceNowEndpoint endpoint) throws Exception {
- super(endpoint);
-
- addDispatcher(ACTION_RETRIEVE, ACTION_SUBJECT_CATEGORIES, this::retrieveCatalogsCategories);
- addDispatcher(ACTION_RETRIEVE, this::retrieveCatalogs);
- }
-
- /*
- * This method retrieves a list of catalogs to which the user has access or
- * a single one if sys_id is defined.
- *
- * Method:
- * - GET
- *
- * URL Format:
- * - /sn_sc/servicecatalog/catalogs
- * - /sn_sc/servicecatalog/catalogs/{sys_id}
- */
- private void retrieveCatalogs(Exchange exchange) throws Exception {
- final Message in = exchange.getIn();
- final Class<?> responseModel = getResponseModel(in);
- final String sysId = getSysID(in);
- final String apiVersion = getApiVersion(in);
-
- Response response = ObjectHelper.isEmpty(sysId)
- ? client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("sn_sc")
- .path(apiVersion)
- .path("servicecatalog")
- .path("catalogs")
- .query(ServiceNowParams.SYSPARM_LIMIT, in)
- .query(ServiceNowParams.SYSPARM_QUERY, in)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(responseModel)
- .invoke(HttpMethod.GET)
- : client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("sn_sc")
- .path(apiVersion)
- .path("servicecatalog")
- .path("catalogs")
- .path(sysId)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(responseModel)
- .invoke(HttpMethod.GET);
-
- setBodyAndHeaders(in, responseModel, response);
- }
-
- /*
- * This method retrieves a list of categories for a catalog.
- *
- * Method:
- * - GET
- *
- * URL Format:
- * - /sn_sc/servicecatalog/catalogs/{sys_id}/categories
- */
- private void retrieveCatalogsCategories(Exchange exchange) throws Exception {
- final Message in = exchange.getIn();
- final Class<?> responseModel = getResponseModel(in);
- final String sysId = getSysID(in);
- final String apiVersion = getApiVersion(in);
-
- Response response = client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("sn_sc")
- .path(apiVersion)
- .path("servicecatalog")
- .path("catalogs")
- .path(ObjectHelper.notNull(sysId, "sysId"))
- .path("categories")
- .query(ServiceNowParams.SYSPARM_TOP_LEVEL_ONLY, in)
- .query(ServiceNowParams.SYSPARM_LIMIT, in)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(ServiceNowParams.SYSPARM_OFFSET, in)
- .query(responseModel)
- .invoke(HttpMethod.GET);
-
- setBodyAndHeaders(in, responseModel, response);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowTableProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowTableProcessor.java b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowTableProcessor.java
deleted file mode 100644
index 8e62408..0000000
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/releases/helsinki/HelsinkiServiceNowTableProcessor.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.servicenow.releases.helsinki;
-
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.component.servicenow.AbstractServiceNowProcessor;
-import org.apache.camel.component.servicenow.ServiceNowEndpoint;
-import org.apache.camel.component.servicenow.ServiceNowParams;
-import org.apache.camel.util.ObjectHelper;
-
-import static org.apache.camel.component.servicenow.ServiceNowConstants.ACTION_CREATE;
-import static org.apache.camel.component.servicenow.ServiceNowConstants.ACTION_DELETE;
-import static org.apache.camel.component.servicenow.ServiceNowConstants.ACTION_MODIFY;
-import static org.apache.camel.component.servicenow.ServiceNowConstants.ACTION_RETRIEVE;
-import static org.apache.camel.component.servicenow.ServiceNowConstants.ACTION_UPDATE;
-
-class HelsinkiServiceNowTableProcessor extends AbstractServiceNowProcessor {
- HelsinkiServiceNowTableProcessor(ServiceNowEndpoint endpoint) throws Exception {
- super(endpoint);
-
- addDispatcher(ACTION_RETRIEVE, this::retrieveRecord);
- addDispatcher(ACTION_CREATE, this::createRecord);
- addDispatcher(ACTION_MODIFY, this::modifyRecord);
- addDispatcher(ACTION_DELETE, this::deleteRecord);
- addDispatcher(ACTION_UPDATE, this::updateRecord);
- }
-
- /*
- * GET
- * https://instance.service-now.com/api/now/table/{tableName}
- * https://instance.service-now.com/api/now/table/{tableName}/{sys_id}
- */
- private void retrieveRecord(Exchange exchange) throws Exception {
- final Message in = exchange.getIn();
- final String tableName = getTableName(in);
- final String apiVersion = getApiVersion(in);
- final Class<?> responseModel = getResponseModel(in, tableName);
- final String sysId = getSysID(in);
-
- Response response = ObjectHelper.isEmpty(sysId)
- ? client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("now")
- .path(apiVersion)
- .path("table")
- .path(tableName)
- .query(ServiceNowParams.SYSPARM_QUERY, in)
- .query(ServiceNowParams.SYSPARM_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_EXCLUDE_REFERENCE_LINK, in)
- .query(ServiceNowParams.SYSPARM_SUPPRESS_PAGINATION_HEADER, in)
- .query(ServiceNowParams.SYSPARM_FIELDS, in)
- .query(ServiceNowParams.SYSPARM_LIMIT, in)
- .query(ServiceNowParams.SYSPARM_OFFSET, in)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(responseModel)
- .invoke(HttpMethod.GET)
- : client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("now")
- .path(apiVersion)
- .path("table")
- .path(tableName)
- .path(sysId)
- .query(ServiceNowParams.SYSPARM_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_EXCLUDE_REFERENCE_LINK, in)
- .query(ServiceNowParams.SYSPARM_FIELDS, in)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(responseModel)
- .invoke(HttpMethod.GET);
-
- setBodyAndHeaders(exchange.getIn(), responseModel, response);
- }
-
- /*
- * POST
- * https://instance.service-now.com/api/now/table/{tableName}
- */
- private void createRecord(Exchange exchange) throws Exception {
- final Message in = exchange.getIn();
- final String tableName = getTableName(in);
- final String apiVersion = getApiVersion(in);
- final Class<?> requestModel = getRequestModel(in, tableName);
- final Class<?> responseModel = getResponseModel(in, tableName);
- final String sysId = getSysID(in);
-
- validateBody(in, requestModel);
-
- Response response = client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("now")
- .path(apiVersion)
- .path("table")
- .path(tableName)
- .query(ServiceNowParams.SYSPARM_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_EXCLUDE_REFERENCE_LINK, in)
- .query(ServiceNowParams.SYSPARM_FIELDS, in)
- .query(ServiceNowParams.SYSPARM_INPUT_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_SUPPRESS_AUTO_SYS_FIELD, in)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(responseModel)
- .invoke(HttpMethod.POST, in.getMandatoryBody());
-
- setBodyAndHeaders(exchange.getIn(), responseModel, response);
- }
-
- /*
- * PUT
- * https://instance.service-now.com/api/now/table/{tableName}/{sys_id}
- */
- private void modifyRecord(Exchange exchange) throws Exception {
- final Message in = exchange.getIn();
- final String tableName = getTableName(in);
- final String apiVersion = getApiVersion(in);
- final Class<?> requestModel = getRequestModel(in, tableName);
- final Class<?> responseModel = getResponseModel(in, tableName);
- final String sysId = getSysID(in);
-
- validateBody(in, requestModel);
-
- Response response = client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("now")
- .path(apiVersion)
- .path("table")
- .path(tableName)
- .path(ObjectHelper.notNull(sysId, "sysId"))
- .query(ServiceNowParams.SYSPARM_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_EXCLUDE_REFERENCE_LINK, in)
- .query(ServiceNowParams.SYSPARM_FIELDS, in)
- .query(ServiceNowParams.SYSPARM_INPUT_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_SUPPRESS_AUTO_SYS_FIELD, in)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(responseModel)
- .invoke(HttpMethod.PUT, in.getMandatoryBody());
-
- setBodyAndHeaders(exchange.getIn(), responseModel, response);
- }
-
- /*
- * DELETE
- * https://instance.service-now.com/api/now/table/{tableName}/{sys_id}
- */
- private void deleteRecord(Exchange exchange) throws Exception {
- final Message in = exchange.getIn();
- final String tableName = getTableName(in);
- final String apiVersion = getApiVersion(in);
- final Class<?> responseModel = getResponseModel(in, tableName);
- final String sysId = getSysID(in);
-
- Response response = client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("now")
- .path(apiVersion)
- .path("table")
- .path(tableName)
- .path(ObjectHelper.notNull(sysId, "sysId"))
- .query(responseModel)
- .invoke(HttpMethod.DELETE, null);
-
- setBodyAndHeaders(exchange.getIn(), responseModel, response);
- }
-
- /*
- * PATCH
- * instance://instance.service-now.com/api/now/table/{tableName}/{sys_id}
- */
- private void updateRecord(Exchange exchange) throws Exception {
- final Message in = exchange.getIn();
- final String tableName = getTableName(in);
- final String apiVersion = getApiVersion(in);
- final Class<?> requestModel = getRequestModel(in, tableName);
- final Class<?> responseModel = getResponseModel(in, tableName);
- final String sysId = getSysID(in);
-
- validateBody(in, requestModel);
-
- Response response = client.reset()
- .types(MediaType.APPLICATION_JSON_TYPE)
- .path("now")
- .path(apiVersion)
- .path("table")
- .path(tableName)
- .path(ObjectHelper.notNull(sysId, "sysId"))
- .query(ServiceNowParams.SYSPARM_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_EXCLUDE_REFERENCE_LINK, in)
- .query(ServiceNowParams.SYSPARM_FIELDS, in)
- .query(ServiceNowParams.SYSPARM_INPUT_DISPLAY_VALUE, in)
- .query(ServiceNowParams.SYSPARM_SUPPRESS_AUTO_SYS_FIELD, in)
- .query(ServiceNowParams.SYSPARM_VIEW, in)
- .query(responseModel)
- .invoke("PATCH", in.getMandatoryBody());
-
- setBodyAndHeaders(exchange.getIn(), responseModel, response);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/resources/META-INF/LICENSE.txt b/components/camel-servicenow/src/main/resources/META-INF/LICENSE.txt
deleted file mode 100644
index 6b0b127..0000000
--- a/components/camel-servicenow/src/main/resources/META-INF/LICENSE.txt
+++ /dev/null
@@ -1,203 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/resources/META-INF/NOTICE.txt b/components/camel-servicenow/src/main/resources/META-INF/NOTICE.txt
deleted file mode 100644
index 2e215bf..0000000
--- a/components/camel-servicenow/src/main/resources/META-INF/NOTICE.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the Apache Camel distribution. ==
- =========================================================================
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- Please read the different LICENSE files present in the licenses directory of
- this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/main/resources/META-INF/services/org/apache/camel/component/servicenow
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/resources/META-INF/services/org/apache/camel/component/servicenow b/components/camel-servicenow/src/main/resources/META-INF/services/org/apache/camel/component/servicenow
deleted file mode 100644
index 38858aa..0000000
--- a/components/camel-servicenow/src/main/resources/META-INF/services/org/apache/camel/component/servicenow
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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
-#
-# 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,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-class=org.apache.camel.component.servicenow.ServiceNowComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java
deleted file mode 100644
index 18772d2..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.camel.component.servicenow;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.servicenow.model.AttachmentMeta;
-import org.junit.Test;
-
-import static org.apache.camel.util.ResourceHelper.resolveResourceAsInputStream;
-
-public class ServiceNowAttachmentTest extends ServiceNowTestSupport {
- @Produce(uri = "direct:servicenow")
- ProducerTemplate template;
-
- @Test
- public void testAttachment() throws Exception {
- List<AttachmentMeta> attachmentMetaList = template.requestBodyAndHeaders(
- "direct:servicenow",
- null,
- kvBuilder()
- .put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_ATTACHMENT)
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowConstants.MODEL, AttachmentMeta.class)
- .put(ServiceNowParams.SYSPARM_QUERY, "content_type=application/octet-stream")
- .put(ServiceNowParams.SYSPARM_LIMIT, 1)
- .build(),
- List.class
- );
-
- assertFalse(attachmentMetaList.isEmpty());
-
- Exchange getExistingResult = template.send(
- "direct:servicenow",
- e -> {
- e.getIn().setHeader(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_ATTACHMENT);
- e.getIn().setHeader(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_CONTENT);
- e.getIn().setHeader(ServiceNowParams.PARAM_SYS_ID.getHeader(), attachmentMetaList.get(0).getId());
- }
- );
-
- assertNotNull(getExistingResult.getIn().getHeader(ServiceNowConstants.CONTENT_META));
- assertNotNull(getExistingResult.getIn().getBody());
- assertTrue(getExistingResult.getIn().getBody() instanceof InputStream);
-
- Map<String, String> contentMeta = getExistingResult.getIn().getHeader(ServiceNowConstants.CONTENT_META, Map.class);
- assertEquals(contentMeta.get("file_name"), attachmentMetaList.get(0).getFileName());
- assertEquals(contentMeta.get("table_name"), attachmentMetaList.get(0).getTableName());
- assertEquals(contentMeta.get("sys_id"), attachmentMetaList.get(0).getId());
-
- Exchange putResult = template.send(
- "direct:servicenow",
- e -> {
- e.getIn().setHeader(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_ATTACHMENT);
- e.getIn().setHeader(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_UPLOAD);
- e.getIn().setHeader(ServiceNowConstants.MODEL, AttachmentMeta.class);
- e.getIn().setHeader(ServiceNowConstants.CONTENT_TYPE, "application/octet-stream");
- e.getIn().setHeader(ServiceNowParams.PARAM_FILE_NAME.getHeader(), UUID.randomUUID().toString());
- e.getIn().setHeader(ServiceNowParams.PARAM_TABLE_NAME.getHeader(), attachmentMetaList.get(0).getTableName());
- e.getIn().setHeader(ServiceNowParams.PARAM_TABLE_SYS_ID.getHeader(), attachmentMetaList.get(0).getTableSysId());
- e.getIn().setBody(resolveResourceAsInputStream(e.getContext().getClassResolver(), "classpath:my-content.txt"));
- }
- );
-
- Exchange getCreatedResult = template.send(
- "direct:servicenow",
- e -> {
- e.getIn().setHeader(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_ATTACHMENT);
- e.getIn().setHeader(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_CONTENT);
- e.getIn().setHeader(ServiceNowParams.PARAM_SYS_ID.getHeader(), putResult.getIn().getBody(AttachmentMeta.class).getId());
- }
- );
-
- assertNotNull(getCreatedResult.getIn().getHeader(ServiceNowConstants.CONTENT_META));
- assertNotNull(getCreatedResult.getIn().getBody());
- assertTrue(getCreatedResult.getIn().getBody() instanceof InputStream);
-
- Exchange deleteResult = template.send(
- "direct:servicenow",
- e -> {
- e.getIn().setHeader(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_ATTACHMENT);
- e.getIn().setHeader(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_DELETE);
- e.getIn().setHeader(ServiceNowParams.PARAM_SYS_ID.getHeader(), putResult.getIn().getBody(AttachmentMeta.class).getId());
- }
- );
-
- if (deleteResult.getException() != null) {
- throw deleteResult.getException();
- }
- }
-
- // *************************************************************************
- //
- // *************************************************************************
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("direct:servicenow")
- .to("servicenow:{{env:SERVICENOW_INSTANCE}}")
- .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
- .to("mock:servicenow");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintComponentAuthTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintComponentAuthTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintComponentAuthTest.java
deleted file mode 100644
index c3b524a..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintComponentAuthTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.servicenow;
-
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.servicenow.model.Incident;
-import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
-import org.junit.Test;
-
-public class ServiceNowBlueprintComponentAuthTest extends CamelBlueprintTestSupport {
- @Override
- protected String getBlueprintDescriptor() {
- return "OSGI-INF/blueprint/blueprint-component-auth.xml";
- }
-
- @Test
- public void testAuth() throws Exception {
- MockEndpoint mock1 = getMockEndpoint("mock:servicenow-1");
- mock1.expectedMessageCount(1);
- MockEndpoint mock2 = getMockEndpoint("mock:servicenow-2");
- mock2.expectedMessageCount(1);
-
- template().sendBodyAndHeaders(
- "direct:servicenow",
- null,
- ServiceNowTestSupport.kvBuilder()
- .put(ServiceNowConstants.RESOURCE, "table")
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowParams.SYSPARM_LIMIT, 10)
- .put(ServiceNowParams.PARAM_TABLE_NAME, "incident")
- .build()
- );
-
- mock1.assertIsSatisfied();
- mock2.assertIsSatisfied();
-
- validate(mock1.getExchanges().get(0));
- validate(mock2.getExchanges().get(0));
- }
-
- private void validate(Exchange exchange) {
- List<Incident> items = exchange.getIn().getBody(List.class);
-
- assertNotNull(items);
- assertTrue(items.size() <= 10);
- assertNotNull(exchange.getIn().getHeader(ServiceNowConstants.OFFSET_FIRST));
- assertNotNull(exchange.getIn().getHeader(ServiceNowConstants.OFFSET_NEXT));
- assertNotNull(exchange.getIn().getHeader(ServiceNowConstants.OFFSET_LAST));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintEndpointAuthTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintEndpointAuthTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintEndpointAuthTest.java
deleted file mode 100644
index 581404c..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowBlueprintEndpointAuthTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.camel.component.servicenow;
-
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.servicenow.model.Incident;
-import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
-import org.junit.Test;
-
-public class ServiceNowBlueprintEndpointAuthTest extends CamelBlueprintTestSupport {
- @Override
- protected String getBlueprintDescriptor() {
- return "OSGI-INF/blueprint/blueprint-endpoint-auth.xml";
- }
-
- @Test
- public void testAuth() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:servicenow");
- mock.expectedMessageCount(1);
-
- template().sendBodyAndHeaders(
- "direct:servicenow",
- null,
- ServiceNowTestSupport.kvBuilder()
- .put(ServiceNowConstants.RESOURCE, "table")
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowParams.SYSPARM_LIMIT, 10)
- .put(ServiceNowParams.PARAM_TABLE_NAME, "incident")
- .build()
- );
-
- mock.assertIsSatisfied();
-
- Exchange exchange = mock.getExchanges().get(0);
- List<Incident> items = exchange.getIn().getBody(List.class);
-
- assertNotNull(items);
- assertTrue(items.size() <= 10);
- assertNotNull(exchange.getIn().getHeader(ServiceNowConstants.OFFSET_FIRST));
- assertNotNull(exchange.getIn().getHeader(ServiceNowConstants.OFFSET_NEXT));
- assertNotNull(exchange.getIn().getHeader(ServiceNowConstants.OFFSET_LAST));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java
deleted file mode 100644
index a06d503..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.servicenow;
-
-import java.util.Map;
-import javax.ws.rs.ProcessingException;
-
-import org.apache.camel.Component;
-import org.apache.camel.component.extension.ComponentVerifierExtension;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupport {
- public ServiceNowComponentVerifierExtensionTest() {
- super(false);
- }
-
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- protected ComponentVerifierExtension getExtension() {
- Component component = context().getComponent("servicenow");
- ComponentVerifierExtension verifier = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new);
-
- return verifier;
- }
-
- // *********************************
- // Parameters validation
- // *********************************
-
- @Test
- public void testParameter() {
- Map<String, Object> parameters = getParameters();
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus());
- }
-
- @Test
- public void testMissingMandatoryParameter() {
- Map<String, Object> parameters = getParameters();
- parameters.remove("instanceName");
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode());
- Assert.assertEquals("instanceName", result.getErrors().get(0).getParameterKeys().iterator().next());
- }
-
- @Test
- public void testMissingMandatoryAuthenticationParameter() {
- Map<String, Object> parameters = getParameters();
- parameters.remove("userName");
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode());
- Assert.assertEquals("userName", result.getErrors().get(0).getParameterKeys().iterator().next());
- }
-
- // *********************************
- // Connectivity validation
- // *********************************
-
- @Test
- public void testConnectivity() {
- Map<String, Object> parameters = getParameters();
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus());
- }
-
- @Test
- public void testConnectivityOnCustomTable() {
- Map<String, Object> parameters = getParameters();
- parameters.put("table", "ticket");
-
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus());
- }
-
- @Test
- public void testConnectivityWithWrongInstance() {
- Map<String, Object> parameters = getParameters();
- parameters.put("instanceName", "unknown-instance");
-
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode());
- Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE));
- Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ProcessingException);
- }
-
- @Test
- public void testConnectivityWithWrongTable() {
- Map<String, Object> parameters = getParameters();
- parameters.put("table", "unknown");
-
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode());
- Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE));
- Assert.assertEquals(400, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE));
- Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException);
- }
-
- @Test
- public void testConnectivityWithWrongAuthentication() {
- Map<String, Object> parameters = getParameters();
- parameters.put("userName", "unknown-user");
- parameters.remove("oauthClientId");
- parameters.remove("oauthClientSecret");
-
- ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.AUTHENTICATION, result.getErrors().get(0).getCode());
- Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE));
- Assert.assertEquals(401, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE));
- Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException);
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("userName"));
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("password"));
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientId"));
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientSecret"));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java
deleted file mode 100644
index 120346a..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.servicenow;
-
-import java.util.Map;
-import javax.ws.rs.ProcessingException;
-
-import org.apache.camel.ComponentVerifier;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport {
- public ServiceNowComponentVerifierTest() {
- super(false);
- }
-
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- protected ComponentVerifier getVerifier() {
- return context().getComponent("servicenow", ServiceNowComponent.class).getVerifier();
- }
-
- // *********************************
- // Parameters validation
- // *********************************
-
- @Test
- public void testParameter() {
- Map<String, Object> parameters = getParameters();
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.PARAMETERS, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.OK, result.getStatus());
- }
-
- @Test
- public void testMissingMandatoryParameter() {
- Map<String, Object> parameters = getParameters();
- parameters.remove("instanceName");
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.PARAMETERS, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifier.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode());
- Assert.assertEquals("instanceName", result.getErrors().get(0).getParameterKeys().iterator().next());
- }
-
- @Test
- public void testMissingMandatoryAuthenticationParameter() {
- Map<String, Object> parameters = getParameters();
- parameters.remove("userName");
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.PARAMETERS, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifier.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode());
- Assert.assertEquals("userName", result.getErrors().get(0).getParameterKeys().iterator().next());
- }
-
- // *********************************
- // Connectivity validation
- // *********************************
-
- @Test
- public void testConnectivity() {
- Map<String, Object> parameters = getParameters();
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.OK, result.getStatus());
- }
-
- @Test
- public void testConnectivityOnCustomTable() {
- Map<String, Object> parameters = getParameters();
- parameters.put("table", "ticket");
-
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.OK, result.getStatus());
- }
-
- @Test
- public void testConnectivityWithWrongInstance() {
- Map<String, Object> parameters = getParameters();
- parameters.put("instanceName", "unknown-instance");
-
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifier.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode());
- Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE));
- Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ProcessingException);
- }
-
- @Test
- public void testConnectivityWithWrongTable() {
- Map<String, Object> parameters = getParameters();
- parameters.put("table", "unknown");
-
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifier.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode());
- Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE));
- Assert.assertEquals(400, result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.HttpAttribute.HTTP_CODE));
- Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException);
- }
-
- @Test
- public void testConnectivityWithWrongAuthentication() {
- Map<String, Object> parameters = getParameters();
- parameters.put("userName", "unknown-user");
- parameters.remove("oauthClientId");
- parameters.remove("oauthClientSecret");
-
- ComponentVerifier.Result result = getVerifier().verify(ComponentVerifier.Scope.CONNECTIVITY, parameters);
-
- Assert.assertEquals(ComponentVerifier.Result.Status.ERROR, result.getStatus());
- Assert.assertEquals(1, result.getErrors().size());
- Assert.assertEquals(ComponentVerifier.VerificationError.StandardCode.AUTHENTICATION, result.getErrors().get(0).getCode());
- Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE));
- Assert.assertEquals(401, result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.HttpAttribute.HTTP_CODE));
- Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifier.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException);
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("userName"));
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("password"));
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientId"));
- Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientSecret"));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java
deleted file mode 100644
index dd524bc..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.servicenow;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.camel.Message;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.servicenow.model.ImportSetResult;
-import org.apache.camel.component.servicenow.model.Incident;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * To set-up ServiceNow for this tests:
- *
- * 1. Create a new web service named u_test_imp_incident targeting incident table
- * 2. Create a mapping (automatic)
- */
-@Ignore
-public class ServiceNowImportSetTest extends ServiceNowTestSupport {
-
- @Test
- public void testIncidentImport() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:servicenow");
-
- mock.reset();
- mock.expectedMessageCount(1);
- mock.expectedHeaderReceived(ServiceNowConstants.RESPONSE_TYPE, ArrayList.class);
-
- IncidentImportRequest incident = new IncidentImportRequest();
- incident.description = UUID.randomUUID().toString();
- incident.correlationId = UUID.randomUUID().toString();
-
- template().sendBodyAndHeaders(
- "direct:servicenow",
- incident,
- kvBuilder()
- .put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_IMPORT)
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_CREATE)
- .put(ServiceNowConstants.REQUEST_MODEL, IncidentImportRequest.class)
- .put(ServiceNowConstants.RESPONSE_MODEL, ImportSetResult.class)
- .put(ServiceNowParams.PARAM_TABLE_NAME, "u_test_imp_incident")
- .build()
- );
-
- mock.assertIsSatisfied();
-
- Message in = mock.getExchanges().get(0).getIn();
-
- // Meta data
- Map<String, String> meta = in.getHeader(ServiceNowConstants.RESPONSE_META, Map.class);
- assertNotNull(meta);
- assertEquals("u_test_imp_incident", meta.get("staging_table"));
-
- // Incidents
- List<ImportSetResult> responses = in.getBody(List.class);
- assertNotNull(responses);
- assertEquals(1, responses.size());
- assertEquals("inserted", responses.get(0).getStatus());
- assertEquals("test_imp_incident", responses.get(0).getTransformMap());
- assertEquals("incident", responses.get(0).getTable());
- }
-
- @Test
- public void testIncidentImportWithRetrieve() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:servicenow");
-
- mock.reset();
- mock.expectedMessageCount(1);
- mock.expectedHeaderReceived(ServiceNowConstants.RESPONSE_TYPE, Incident.class);
-
- IncidentImportRequest incident = new IncidentImportRequest();
- incident.description = UUID.randomUUID().toString();
-
- template().sendBodyAndHeaders(
- "direct:servicenow",
- incident,
- kvBuilder()
- .put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_IMPORT)
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_CREATE)
- .put(ServiceNowConstants.REQUEST_MODEL, IncidentImportRequest.class)
- .put(ServiceNowConstants.RESPONSE_MODEL, Incident.class)
- .put(ServiceNowConstants.RETRIEVE_TARGET_RECORD, true)
- .put(ServiceNowParams.PARAM_TABLE_NAME, "u_test_imp_incident")
- .build()
- );
-
- mock.assertIsSatisfied();
-
- Incident response = mock.getExchanges().get(0).getIn().getBody(Incident.class);
- assertNotNull(response);
- assertEquals(incident.description, response.getDescription());
- assertNotNull(response.getNumber());
- assertNotNull(response.getId());
- }
-
- // *************************************************************************
- //
- // *************************************************************************
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("direct:servicenow")
- .to("servicenow:{{env:SERVICENOW_INSTANCE}}")
- .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
- .to("mock:servicenow");
- }
- };
- }
-
- // *************************************************************************
- //
- // *************************************************************************
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private static final class IncidentImportRequest {
- @JsonProperty("description")
- public String description;
- @JsonProperty("correlation_id")
- public String correlationId;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java
deleted file mode 100644
index e99cb56..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.servicenow;
-
-import java.util.Map;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.apache.camel.component.extension.MetaDataExtension;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ServiceNowMetaDataExtensionTest extends ServiceNowTestSupport {
- private static final Logger LOGGER = LoggerFactory.getLogger(ServiceNowMetaDataExtensionTest.class);
-
- public ServiceNowMetaDataExtensionTest() {
- super(false);
- }
-
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- protected ServiceNowComponent getComponent() {
- return context().getComponent("servicenow", ServiceNowComponent.class);
- }
-
- protected MetaDataExtension getExtension() {
- return getComponent().getExtension(MetaDataExtension.class).orElseThrow(IllegalStateException::new);
- }
-
- // *********************************
- //
- // *********************************
-
- @Test
- public void testMetaData() throws Exception {
- Map<String, Object> parameters = getParameters();
- parameters.put("objectType", "table");
- parameters.put("objectName", "incident");
- //parameters.put("object.sys_user.fields", "first_name,last_name");
- //parameters.put("object.incident.fields", "caller_id,severity,resolved_at,sys_id");
- //parameters.put("object.incident.fields", "^sys_.*$");
- //parameters.put("object.task.fields", "");
-
- MetaDataExtension.MetaData result = getExtension().meta(parameters).orElseThrow(IllegalStateException::new);
-
- Assert.assertEquals("application/schema+json", result.getAttribute(MetaDataExtension.MetaData.CONTENT_TYPE));
- Assert.assertEquals(JsonNode.class, result.getAttribute(MetaDataExtension.MetaData.JAVA_TYPE));
- Assert.assertTrue(result.getPayload(JsonNode.class).hasNonNull("definitions"));
- Assert.assertTrue(result.getPayload(JsonNode.class).get("definitions").hasNonNull("guid"));
- Assert.assertTrue(result.getPayload(JsonNode.class).get("definitions").hasNonNull("date"));
- Assert.assertTrue(result.getPayload(JsonNode.class).get("definitions").hasNonNull("time"));
- Assert.assertTrue(result.getPayload(JsonNode.class).get("definitions").hasNonNull("date-time"));
- Assert.assertTrue(result.getPayload(JsonNode.class).hasNonNull("properties"));
-
- //LOGGER.info(
- // new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result.getPayload())
- //);
- }
-
-
- @Test(expected = UnsupportedOperationException.class)
- public void testMInvalidObjectType() throws Exception {
- Map<String, Object> parameters = getParameters();
- parameters.put("objectType", "test");
- parameters.put("objectName", "incident");
-
- getExtension().meta(parameters);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java
deleted file mode 100644
index 429bec2..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.servicenow;
-
-import java.util.List;
-
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.servicenow.model.Scorecard;
-import org.junit.Test;
-
-public class ServiceNowScorecardTest extends ServiceNowTestSupport {
- @Produce(uri = "direct:servicenow")
- ProducerTemplate template;
-
- @Test
- public void testScorecard() throws Exception {
- List<Scorecard> scorecardList = template.requestBodyAndHeaders(
- "direct:servicenow",
- null,
- kvBuilder()
- .put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_SCORECARDS)
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowConstants.ACTION_SUBJECT, ServiceNowConstants.ACTION_SUBJECT_PERFORMANCE_ANALYTICS)
- .put(ServiceNowConstants.MODEL, Scorecard.class)
- .build(),
- List.class
- );
-
- assertFalse(scorecardList.isEmpty());
- }
-
- // *************************************************************************
- //
- // *************************************************************************
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("direct:servicenow")
- .to("servicenow:{{env:SERVICENOW_INSTANCE}}")
- .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
- .to("mock:servicenow");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109da7c9/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java
deleted file mode 100644
index 9562be8..0000000
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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
- *
- * 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.camel.component.servicenow;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-
-public class ServiceNowServiceCatalogTest extends ServiceNowTestSupport {
- @Produce(uri = "direct:servicenow")
- ProducerTemplate template;
-
- @Test
- public void testRetrieveServiceCatalogsAndCategories() throws Exception {
- List<Map> result1 = template.requestBodyAndHeaders(
- "direct:servicenow",
- null,
- kvBuilder()
- .put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_SERVICE_CATALOG)
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .build(),
- List.class
- );
-
- assertFalse(result1.isEmpty());
-
- List<Map> result2 = template.requestBodyAndHeaders(
- "direct:servicenow",
- null,
- kvBuilder()
- .put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_SERVICE_CATALOG)
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowConstants.ACTION_SUBJECT, ServiceNowConstants.ACTION_SUBJECT_CATEGORIES)
- .put(ServiceNowParams.PARAM_SYS_ID, result1.get(0).get("sys_id"))
- .build(),
- List.class
- );
-
- assertFalse(result2.isEmpty());
- }
-
- @Test(expected = CamelExecutionException.class)
- public void testWrongSubject() throws Exception {
- List<Map> result = template.requestBodyAndHeaders(
- "direct:servicenow",
- null,
- kvBuilder()
- .put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_SERVICE_CATALOG)
- .put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE)
- .put(ServiceNowConstants.ACTION_SUBJECT, "Invalid")
- .build(),
- List.class
- );
-
- assertFalse(result.isEmpty());
- }
-
- // *************************************************************************
- //
- // *************************************************************************
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("direct:servicenow")
- .to("servicenow:{{env:SERVICENOW_INSTANCE}}")
- .to("log:org.apache.camel.component.servicenow?level=INFO&showAll=true")
- .to("mock:servicenow");
- }
- };
- }
-}