2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.artifact.handler.utils;
26 import static org.junit.Assert.assertTrue;
27 import java.nio.charset.Charset;
28 import org.apache.commons.io.IOUtils;
29 import org.json.JSONObject;
30 import org.junit.Test;
31 import org.powermock.reflect.Whitebox;
33 public class ArtifactHandlerProviderUtilTest {
35 @Test(expected = Exception.class)
36 public void testProcessTemplate() throws Exception {
37 String artifact_conetent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
38 .getResourceAsStream("templates/reference_template.json"), Charset.defaultCharset());
39 JSONObject obj = new JSONObject();
40 obj.put("artifact-name", "reference_JunitTestArtifact");
41 obj.put("artifact-version", "0.01");
42 obj.put("artifact-contents", artifact_conetent);
43 ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
44 ahprovider.processTemplate(obj.toString());
47 @Test(expected = Exception.class)
48 public void testcreateDummyRequestData() throws Exception {
49 String artifact_conetent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
50 .getResourceAsStream("templates/reference_template.json"), Charset.defaultCharset());
51 JSONObject obj = new JSONObject();
52 obj.put("artifact-name", "reference_JunitTestArtifact");
53 obj.put("artifact-version", "0.01");
54 obj.put("artifact-contents", artifact_conetent);
55 ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
56 String requestInfo = ahprovider.createDummyRequestData();
60 public void testEscapeSql() throws Exception {
61 String testStr = "Test String is 'test'";
62 ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
63 ahprovider.escapeSql(testStr);
68 public void testGetRandom() throws Exception {
69 ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
70 Whitebox.invokeMethod(ahprovider, "getRandom");
75 public void testEscapeUtils() throws Exception {
76 String str = "The Test string is 'test'";
77 EscapeUtils.escapeSql(str);