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;
38 import org.springframework.util.ResourceUtils;
40 @SpringBootTest(classes = { DataSchemaGenerator.class, ModelComparator.class, DataSchemaHelper.class, TableBuilder.class,
41 HashInfoDataGenerator.class, BackwardCompatibilityChecker.class }, properties = {
42 "green-field-installation=false" })
43 public class DataSchemaGeneratorTest {
45 private DataSchemaGenerator dataSchemaGenerator;
46 @Value("${green-field-installation}")
47 private boolean isGreenFieldInstallation;
48 @Value("${schema.data.baseline}")
49 private String baselineDataSqlFile;
50 @Value("${schema.data.output}")
51 private String actualResultSqlFile;
54 void prepareSchemaTest() throws IOException {
56 dataSchemaGenerator.prepareSchema();
58 Assertions.assertFalse(isGreenFieldInstallation);
59 //exclude commit statement in the prepare statement as it will be added in the later stage at the end of the schema.
60 Assertions.assertTrue(TestHelper.filesCompareByLine(ResourceUtils.getFile("classpath:" + baselineDataSqlFile)
61 .toPath(), Paths.get(actualResultSqlFile), "COMMIT;", ""));
65 public void tearDown() {
66 assertTrue(Paths.get(actualResultSqlFile).toFile().delete());