2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2024 Ericsson
4 * Modifications Copyright (C) 2024 OpenInfra Foundation Europe
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
21 package org.oran.smo.teiv.pgsqlgenerator.schema.model;
24 import java.io.IOException;
26 import org.oran.smo.teiv.pgsqlgenerator.schema.BackwardCompatibilityChecker;
27 import org.junit.jupiter.api.AfterAll;
28 import org.junit.jupiter.api.Test;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.beans.factory.annotation.Value;
31 import org.springframework.boot.test.context.SpringBootTest;
32 import org.springframework.core.io.ClassPathResource;
34 import org.oran.smo.teiv.pgsqlgenerator.TestHelper;
35 import org.oran.smo.teiv.pgsqlgenerator.YangParser;
37 import static org.junit.jupiter.api.Assertions.assertTrue;
39 @SpringBootTest(classes = { HashInfoDataGenerator.class, ModelSchemaGenerator.class, YangParser.class,
40 BackwardCompatibilityChecker.class }, properties = { "green-field-installation=false" })
41 public class ModelSchemaGeneratorTest {
44 private ModelSchemaGenerator modelSchemaGenerator;
46 static File generatedResultFile;
47 static File tempBaselineFile;
48 @Value("${test-result.model}")
49 private String expectedResultSqlFile;
50 @Value("${schema.model.output}")
51 private String actualResultSqlFile;
52 @Value("${schema.model.skeleton}")
53 private String skeletonModelSqlFile;
54 @Value("${schema.model.baseline}")
55 private String baselineModelSqlFile;
56 @Value("${schema.model.temp-baseline}")
57 private String tempBaselineModelSqlFile;
60 void prepareSchemaTest() throws IOException {
62 modelSchemaGenerator.prepareSchema();
63 File skeletionFile = new ClassPathResource(skeletonModelSqlFile).getFile();
64 generatedResultFile = new File(actualResultSqlFile);
65 tempBaselineFile = new File(tempBaselineModelSqlFile);
68 assertTrue(generatedResultFile.exists());
69 assertTrue(tempBaselineFile.exists());
70 assertTrue(TestHelper.filesCompareByLine(skeletionFile.toPath(), generatedResultFile.toPath()));
71 assertTrue(TestHelper.filesCompareByLine(new File(baselineModelSqlFile).toPath(), tempBaselineFile.toPath()));
75 public static void teardown() {
76 assertTrue(generatedResultFile.delete());
77 assertTrue(tempBaselineFile.delete());