2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018-2019 Huawei. 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=========================================================
20 package org.onap.datalake.feeder.controller;
22 import static org.junit.Assert.assertEquals;
23 import static org.mockito.Mockito.when;
25 import java.io.IOException;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.mockito.InjectMocks;
30 import org.mockito.Mock;
31 import org.mockito.junit.MockitoJUnitRunner;
32 import org.onap.datalake.feeder.config.ApplicationConfiguration;
33 import org.onap.datalake.feeder.service.PullService;
35 @RunWith(MockitoJUnitRunner.class)
36 public class FeederControllerTest {
38 private PullService pullService1;
41 private ApplicationConfiguration config;
44 private FeederController feederController;
47 public void testStart() throws IOException {
48 when(pullService1.isRunning()).thenReturn(true);
49 String start = feederController.start();
50 assertEquals("{\"running\": true}", start);
52 when(pullService1.isRunning()).thenReturn(false);
53 start = feederController.start();
54 assertEquals("{\"running\": true}", start);
58 public void testStop() {
59 when(pullService1.isRunning()).thenReturn(true);
60 String stop = feederController.stop();
61 assertEquals("{\"running\": false}", stop);
63 when(pullService1.isRunning()).thenReturn(false);
64 stop = feederController.stop();
65 assertEquals("{\"running\": false}", stop);
69 public void testStatus() {
70 when(pullService1.isRunning()).thenReturn(false);
71 when(config.getDatalakeVersion()).thenReturn("0.0.1");
73 String status = feederController.status();
74 assertEquals("{\"version\": \"0.0.1\", \"running\": false}", status);