summaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/test/java
diff options
context:
space:
mode:
authorChuanyuChen <chenchuanyu@huawei.com>2022-07-30 09:39:36 +0800
committerChuanyuChen <chenchuanyu@huawei.com>2022-08-03 10:25:50 +0800
commitc63412acfab7c50803bdd0dcf848b3a91b3f565f (patch)
tree6db3531941ba930e0ad5a91e8bf87b6ad4c48781 /intentanalysis/src/test/java
parent0c41af52f3f453219a0240cf54ea321829a49c0e (diff)
Add unit test for intent analysis
Add unit test for intent analysis Issue-ID: USECASEUI-692 Signed-off-by: ChuanyuChen <chenchuanyu@huawei.com> Change-Id: If7c8a1ca56c1e8cc07e91729b3d2e38ddb2c855b
Diffstat (limited to 'intentanalysis/src/test/java')
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/IntentAnalysisApplicationTests.java53
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java56
2 files changed, 109 insertions, 0 deletions
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/IntentAnalysisApplicationTests.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/IntentAnalysisApplicationTests.java
new file mode 100644
index 0000000..529f08d
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/IntentAnalysisApplicationTests.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.onap.usecaseui.intentanalysis.test;
+
+import java.io.IOException;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.mybatis.spring.annotation.MapperScan;
+import org.onap.usecaseui.intentanalysis.util.SpringContextUtil;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+@SpringBootApplication(exclude = {SecurityAutoConfiguration.class}, scanBasePackages = "org.onap.usecaseui.intentanalysis")
+@MapperScan(basePackages = {"org.onap.usecaseui.intentanalysis.mapper"})
+@EnableScheduling
+
+public class IntentAnalysisApplicationTests {
+
+ public static void main(String[] args) throws Exception {
+ ApplicationContext applicationContext = SpringApplication.run(IntentAnalysisApplicationTests.class, args);
+ SpringContextUtil.setApplicationContext(applicationContext);
+ }
+
+ @Bean
+ public OncePerRequestFilter accessTokenFilter() {
+ return new OncePerRequestFilter() {
+ @Override
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
+ FilterChain filterChain) throws ServletException, IOException {
+ filterChain.doFilter(request, response);
+ }
+ };
+ }
+}
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java
new file mode 100644
index 0000000..3a692c0
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.onap.usecaseui.intentanalysis.test.service;
+
+import java.io.IOException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.onap.usecaseui.intentanalysis.test.IntentAnalysisApplicationTests;
+import org.onap.usecaseui.intentanalysis.util.SpringContextUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@SpringBootTest(classes = IntentAnalysisApplicationTests.class)
+@RunWith(SpringRunner.class)
+public class IntentServiceTest extends AbstractJUnit4SpringContextTests {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(IntentServiceTest.class);
+
+ @Autowired
+ private IntentService intentService;
+
+ @Before
+ public void setUp() {
+ SpringContextUtil.setApplicationContext(applicationContext);
+ }
+
+ @Test
+ public void testCreateIntentSuccess() throws IOException {
+ Intent intent = new Intent();
+ intent.setIntentId("testUUID");
+ intent.setIntentName("testIntentName");
+ //ToDo
+ //Intent intentTmp = intentService.createIntent(intent);
+ Assert.assertNotNull(intent);
+ }
+}