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=========================================================
21 package org.openecomp.sdc.common.util;
23 import org.junit.Test;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNull;
28 public class ThreadLocalsHolderTest {
31 public void validateSetAngGetMdcProcessReturnsValidThreadLocalBoolean() {
32 final boolean testBoolean01 = false;
33 final boolean testBoolean02 = true;
35 ThreadLocalsHolder.setMdcProcessed(testBoolean01);
36 assertEquals(ThreadLocalsHolder.isMdcProcessed(), testBoolean01);
37 ThreadLocalsHolder.setMdcProcessed(testBoolean02);
38 assertEquals(ThreadLocalsHolder.isMdcProcessed(), testBoolean02);
42 public void validateSetAngGetUUIDReturnsValidThreadLocalString() {
43 final String UUID01 = "testId01";
44 final String UUID02 = "testId02";
46 ThreadLocalsHolder.setUuid(UUID01);
47 assertEquals(ThreadLocalsHolder.getUuid(), UUID01);
48 ThreadLocalsHolder.setUuid(UUID02);
49 assertEquals(ThreadLocalsHolder.getUuid(), UUID02);
53 public void validateSetAngGetRequestStartTimeReturnsValidThreadLocalString() {
54 final Long requestStartTime01 = 10L;
55 final Long requestStartTime02 = 50L;
57 ThreadLocalsHolder.setRequestStartTime(requestStartTime01);
58 assertEquals(ThreadLocalsHolder.getRequestStartTime(), requestStartTime01);
59 ThreadLocalsHolder.setRequestStartTime(requestStartTime02);
60 assertEquals(ThreadLocalsHolder.getRequestStartTime(), requestStartTime02);
64 public void validateCleanupResetsAllParameters() {
65 final Long requestStartTime = 10L;
66 final String UUID = "testId01";
67 final boolean testBoolean = true;
69 ThreadLocalsHolder.setMdcProcessed(testBoolean);
70 ThreadLocalsHolder.setUuid(UUID);
71 ThreadLocalsHolder.setRequestStartTime(requestStartTime);
73 ThreadLocalsHolder.cleanup();
75 assertNull(ThreadLocalsHolder.getRequestStartTime());
76 assertNull(ThreadLocalsHolder.getUuid());
77 assertEquals(ThreadLocalsHolder.isMdcProcessed(), false);