Adjust to yangtools-2.0.0 changes
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / JMXGeneratorFileNamesValidationTest.java
1 /*
2  * Copyright (c) 2013 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.controller.config.yangjmxgenerator.plugin;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertThat;
13 import static org.junit.Assert.assertTrue;
14 import static org.junit.Assert.fail;
15
16 import com.google.common.collect.ImmutableSet;
17 import java.util.Optional;
18 import org.junit.Test;
19 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
20 import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslatorTest;
21
22 public class JMXGeneratorFileNamesValidationTest extends JMXGeneratorTest {
23
24     @Test
25     public void test() {
26         map.clear();
27         map.put(JMXGenerator.NAMESPACE_TO_PACKAGE_PREFIX + "1",
28                 ConfigConstants.CONFIG_NAMESPACE + ":test:files1"
29                         + JMXGenerator.NAMESPACE_TO_PACKAGE_DIVIDER
30                         + PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX);
31         map.put(JMXGenerator.NAMESPACE_TO_PACKAGE_PREFIX + "2",
32                 ConfigConstants.CONFIG_NAMESPACE + ":test:files"
33                         + JMXGenerator.NAMESPACE_TO_PACKAGE_DIVIDER
34                         + PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX);
35
36         map.put(JMXGenerator.MODULE_FACTORY_FILE_BOOLEAN, "randomValue");
37         jmxGenerator.setAdditionalConfig(map);
38         try {
39             jmxGenerator.generateSources(context, outputBaseDir, ImmutableSet.of(testFilesModule, testFiles1Module),
40                 m -> Optional.empty());
41             fail();
42         } catch (RuntimeException e) {
43             final Throwable cause = e.getCause();
44             assertNotNull(cause);
45             assertTrue(cause.toString() + " is unexpected", cause instanceof IllegalStateException);
46             assertThat(cause.getMessage(),
47                     containsString("Name conflict in generated files"));
48             assertThat(cause.getMessage(), containsString("DtoA.java"));
49         }
50     }
51
52 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.