2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2023 Nordix Foundation.
4 * Copyright (C) 2020 Nokia. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.oran.datafile.controllers;
24 import static org.junit.jupiter.api.Assertions.assertTrue;
25 import static org.mockito.Mockito.doReturn;
27 import org.junit.jupiter.api.BeforeEach;
28 import org.junit.jupiter.api.Test;
29 import org.junit.jupiter.api.extension.ExtendWith;
30 import org.mockito.Mock;
31 import org.mockito.junit.jupiter.MockitoExtension;
32 import org.oran.datafile.model.Counters;
33 import org.oran.datafile.tasks.CollectAndReportFiles;
34 import org.springframework.http.HttpHeaders;
35 import org.springframework.http.ResponseEntity;
36 import reactor.core.publisher.Mono;
38 @ExtendWith(MockitoExtension.class)
39 public class StatusControllerTest {
41 CollectAndReportFiles scheduledTasksMock;
43 StatusController controllerUnderTest;
47 controllerUnderTest = new StatusController(scheduledTasksMock);
51 public void heartbeat_success() {
52 HttpHeaders httpHeaders = new HttpHeaders();
54 Mono<ResponseEntity<String>> result = controllerUnderTest.heartbeat(httpHeaders);
56 String body = result.block().getBody();
57 assertTrue(body.startsWith("I'm living!"));
61 public void status() {
62 Counters counters = new Counters();
63 doReturn(counters).when(scheduledTasksMock).getCounters();
65 HttpHeaders httpHeaders = new HttpHeaders();
67 Mono<ResponseEntity<String>> result = controllerUnderTest.status(httpHeaders);
69 String body = result.block().getBody();
70 System.out.println(body);