2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.java.api.generator;
10 import static org.junit.Assert.assertNotNull;
13 import java.io.IOException;
14 import java.net.URISyntaxException;
15 import java.nio.file.Files;
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
20 public class Mdsal738Test extends BaseCompilationTest {
21 private File sourcesOutputDir;
22 private File compiledOutputDir;
25 public void before() throws IOException, URISyntaxException {
26 sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal738");
27 compiledOutputDir = CompilationTestUtils.compilerOutput("mdsal738");
32 CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
36 public void testUnionOfDecimal64() throws IOException, URISyntaxException {
37 generateTestSources("/compilation/mdsal738", sourcesOutputDir);
38 final var pmDataType = FileSearchUtil.getFiles(sourcesOutputDir).get("PmDataType.java");
39 assertNotNull(pmDataType);
41 final var content = Files.readString(pmDataType.toPath());
42 FileSearchUtil.assertFileContainsConsecutiveLines(pmDataType, content,
43 " public String stringValue() {",
44 " if (_uint64 != null) {",
45 " return _uint64.toCanonicalString();",
47 " if (_int64 != null) {",
48 " return _int64.toString();",
50 " if (_decimal64 != null) {",
51 " return _decimal64.toCanonicalString();",
53 " throw new IllegalStateException(\"No value assigned\");",
56 CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);