Allow set values in properties of type timestamp
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / tosca / validators / TimestampValidatorTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2022 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        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.
15  *
16  *  SPDX-License-Identifier: Apache-2.0
17  *  ============LICENSE_END=========================================================
18  *
19  *
20  */
21
22 package org.openecomp.sdc.be.model.tosca.validators;
23
24 import org.junit.jupiter.api.Test;
25
26 import static org.junit.jupiter.api.Assertions.assertFalse;
27 import static org.junit.jupiter.api.Assertions.assertTrue;
28
29 class TimestampValidatorTest {
30
31     private static final TimestampValidator validator = TimestampValidator.getInstance();
32
33     @Test
34     void testTimestampValidator_Success() {
35         assertTrue(validator.isValid(null, null));
36         assertTrue(validator.isValid("", null));
37         assertTrue(validator.isValid("2001-12-15T02:59:43.1Z", null));
38         assertTrue(validator.isValid("2001-12-14t21:59:43.10-05:00", null));
39         assertTrue(validator.isValid("2001-12-15 2:59:43.10", null));
40         assertTrue(validator.isValid("2001-12-15 02:59:43.10", null));
41         assertTrue(validator.isValid("2002-12-14", null));
42         assertTrue(validator.isValid("2001-12-14 21:59:43.10+00", null));
43         assertTrue(validator.isValid("2001-12-14 21:59:43.10 -5", null));
44     }
45
46     @Test
47     void testTimestampValidator_UnSuccess() {
48         assertFalse(validator.isValid("2022-22-22,", null));
49         assertFalse(validator.isValid("2022-01-01 25:61:61,", null));
50
51     }
52 }