2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 China Mobile. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.datalake.des.controller;
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.Mockito.when;
26 import java.io.IOException;
27 import java.sql.SQLException;
28 import java.util.HashMap;
31 import javax.servlet.http.HttpServletResponse;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35 import org.mockito.Mock;
36 import org.mockito.junit.MockitoJUnitRunner;
37 import org.onap.datalake.des.repository.DataExposureRepository;
38 import org.springframework.validation.BindingResult;
41 * Test Data Exposure Controller.
45 @RunWith(MockitoJUnitRunner.class)
46 public class DataExposureControllerTest {
49 private HttpServletResponse httpServletResponse;
52 private DataExposureRepository dataExposureRepository;
55 private BindingResult mockBindingResult;
57 @Test(expected = NullPointerException.class)
58 public void testServe()
59 throws IOException, NoSuchFieldException, IllegalAccessException, ClassNotFoundException, SQLException {
60 DataExposureController dataExposureController = new DataExposureController();
61 String serviceId = "test";
62 Map<String, String> requestMap = new HashMap<String, String>();
63 requestMap.put("name", "oteNB5309");
64 HashMap<String, Object> result = dataExposureController.serve(serviceId, requestMap, mockBindingResult,
66 assertEquals(null, result);
67 when(mockBindingResult.hasErrors()).thenReturn(true);