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.data;
23 import static org.junit.jupiter.api.Assertions.assertTrue;
25 import java.io.IOException;
26 import java.nio.file.Paths;
28 import org.oran.smo.teiv.pgsqlgenerator.schema.BackwardCompatibilityChecker;
29 import org.junit.jupiter.api.AfterEach;
30 import org.junit.jupiter.api.Assertions;
31 import org.junit.jupiter.api.Test;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.beans.factory.annotation.Value;
34 import org.springframework.boot.test.context.SpringBootTest;
36 import org.oran.smo.teiv.pgsqlgenerator.TestHelper;
37 import org.oran.smo.teiv.pgsqlgenerator.schema.model.HashInfoDataGenerator;
39 @SpringBootTest(classes = { DataSchemaGenerator.class, ModelComparator.class, DataSchemaHelper.class, TableBuilder.class,
40 HashInfoDataGenerator.class, BackwardCompatibilityChecker.class }, properties = {
41 "green-field-installation=false" })
42 public class DataSchemaGeneratorTest {
44 private DataSchemaGenerator dataSchemaGenerator;
45 @Value("${green-field-installation}")
46 private boolean isGreenFieldInstallation;
47 @Value("${schema.data.baseline}")
48 private String baselineDataSqlFile;
49 @Value("${schema.data.output}")
50 private String actualResultSqlFile;
53 void prepareSchemaTest() throws IOException {
55 dataSchemaGenerator.prepareSchema();
57 Assertions.assertFalse(isGreenFieldInstallation);
58 //exclude commit statement in the prepare statement as it will be added in the later stage at the end of the schema.
59 Assertions.assertTrue(TestHelper.filesCompareByLine(Paths.get(baselineDataSqlFile), Paths.get(actualResultSqlFile),
64 public void tearDown() {
65 assertTrue(Paths.get(actualResultSqlFile).toFile().delete());