2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.logging.slf4j;
19 import static org.testng.Assert.assertEquals;
20 import static org.testng.Assert.assertTrue;
22 import org.openecomp.sdc.logging.api.ContextData;
23 import org.testng.annotations.Test;
26 * Unit-test retrieving values from client-provided request data.
31 public class RequestContextProviderTest {
34 public void valuesEmptyWhenInputEmpty() {
35 RequestContextProvider provider = new RequestContextProvider(ContextData.builder().build());
36 assertTrue(provider.values().isEmpty());
40 public void serviceNameReturnedWhenSupplied() {
41 final String service = "supplied-service-name";
42 RequestContextProvider provider =
43 new RequestContextProvider(ContextData.builder().serviceName(service).build());
44 assertEquals(provider.values().get(ContextField.SERVICE_NAME), service);
48 public void partnerNameReturnedWhenSupplied() {
49 final String partner = "supplied-partner-name";
50 RequestContextProvider provider =
51 new RequestContextProvider(ContextData.builder().partnerName(partner).build());
52 assertEquals(provider.values().get(ContextField.PARTNER_NAME), partner);
56 public void requestIdReturnedWhenSupplied() {
57 final String request = "supplied-request-id";
58 RequestContextProvider provider =
59 new RequestContextProvider(ContextData.builder().requestId(request).build());
60 assertEquals(provider.values().get(ContextField.REQUEST_ID), request);