2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2020,2022 Nordix Foundation
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=========================================================
22 package org.onap.policy.apex.testsuites.integration.common.model;
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue;
29 import java.io.IOException;
30 import java.nio.file.Files;
31 import java.nio.file.Path;
32 import java.util.Comparator;
33 import org.junit.Test;
34 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
37 * Test the sample domain model saver.
39 public class SampleDomainModelSaverTest {
42 public void testSampleDomainModelSaver() throws IOException, ApexException {
43 assertThatThrownBy(() -> SampleDomainModelSaver.main(null)).isInstanceOf(NullPointerException.class);
46 { "two", "arguments" };
48 SampleDomainModelSaver.main(args0);
50 Path tempDirectory = Files.createTempDirectory("ApexModelTempDir");
52 { tempDirectory.toString() };
54 SampleDomainModelSaver.main(args1);
56 File tempDir = new File(tempDirectory.toString());
57 assertTrue(tempDir.isDirectory());
58 assertEquals(5, tempDir.listFiles().length);
60 Files.walk(tempDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);