2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Nokia. 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=========================================================
22 package org.onap.vid.controller;
25 import static org.assertj.core.api.Assertions.assertThat;
26 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
28 import javax.ws.rs.InternalServerErrorException;
29 import org.junit.Before;
30 import org.junit.Test;
32 public class LogfilePathCreatorTest {
34 private static final String AUDIT = "audit";
35 private static final String ERROR = "error";
36 private static final String METRICS = "metrics";
38 private LogfilePathCreator creator;
42 creator = new LogfilePathCreator();
46 public void shouldThrowInternalServerErrorException_whenLogfileDoesntExist() {
47 String loggerName = "notExisting";
48 assertThatExceptionOfType(InternalServerErrorException.class)
49 .isThrownBy(() -> creator.getLogfilePath(loggerName))
50 .withMessage(String.format("logfile for %s not found", loggerName));
54 public void shouldReturnAuditPath_whenAuditNameIsGiven() {
55 assertThat(creator.getLogfilePath(AUDIT)).isEqualTo("logs/EELF/audit.log");
59 public void shouldReturnErrorPath_whenErrorNameIsGiven() {
60 assertThat(creator.getLogfilePath(ERROR)).isEqualTo("logs/EELF/error.log");
64 public void shouldReturnMetricsPath_whenMetricsNameIsGiven() {
65 assertThat(creator.getLogfilePath(METRICS)).isEqualTo("logs/EELF/metrics.log");