d1f62d3eda7b0f84a5d4d4c57c3755175728f794
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / test / java / org / opendaylight / mdsal / binding / java / api / generator / test / Bug5151Test.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.java.api.generator.test;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.io.File;
14 import java.util.Map;
15 import org.junit.Test;
16
17 /**
18  * Bug5151 involves adding <code>{@literal @}return</code> annotations to accessor methods.
19  */
20 public class Bug5151Test extends BaseCompilationTest {
21
22     private static final String BUG_ID = "bug5151";
23
24     @Test
25     public void test() throws Exception {
26         final File sourcesOutputDir = CompilationTestUtils.generatorOutput(BUG_ID);
27         final File compiledOutputDir = CompilationTestUtils.compilerOutput(BUG_ID);
28         generateTestSources(CompilationTestUtils.FS + "compilation" + CompilationTestUtils.FS + BUG_ID,
29             sourcesOutputDir);
30
31         // Test if sources are compilable
32         CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
33
34         final Map<String, File> generatedFiles = FileSearchUtil.getFiles(sourcesOutputDir);
35         assertEquals(13, generatedFiles.size());
36
37         final File fooContainerFile = generatedFiles.get("FooContainer.java");
38         assertNotNull(fooContainerFile);
39         FileSearchUtil.assertFileContains(fooContainerFile,
40             "@return <code>java.lang.String</code> <code>fooInContainer</code>, or <code>null</code> if not present");
41
42         final File fooDataFile = generatedFiles.get("FooData.java");
43         assertNotNull(fooDataFile);
44         FileSearchUtil.assertFileContains(fooDataFile,
45             "FooContainer</code> <code>fooContainer</code>, or <code>null</code> if not present");
46
47         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
48     }
49 }