2 * ============LICENSE_START=======================================================
3 * PNF-REGISTRATION-HANDLER
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.onap.pnfsimulator.simulator;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.junit.runners.Parameterized;
28 import java.time.Instant;
29 import java.util.Arrays;
30 import java.util.Collection;
32 import static org.assertj.core.api.Assertions.assertThat;
34 @RunWith(Parameterized.class)
35 public class KeywordsExtractorValidTimestampPrimitiveTest {
36 private final String keyword;
37 private KeywordsExtractor keywordsExtractor;
39 private static final Collection VALID_TIMESTAMP_KEYWORDS = Arrays.asList(new Object[][]{
40 {"#TimestampPrimitive"}
43 public KeywordsExtractorValidTimestampPrimitiveTest(String keyword) {
44 this.keyword = keyword;
49 this.keywordsExtractor = new KeywordsExtractor();
52 @Parameterized.Parameters
53 public static Collection data() {
54 return VALID_TIMESTAMP_KEYWORDS;
58 public void checkValidRandomStringKeyword() {
59 long currentTimestamp = Instant.now().getEpochSecond();
60 Long timestamp = keywordsExtractor.substitutePrimitiveKeyword(this.keyword);
61 long afterExecution = Instant.now().getEpochSecond();
63 assertThat(timestamp).isBetween(currentTimestamp, afterExecution);