Remove yang-maven-plugin interfaces
[yangtools.git] / plugin / yang-maven-plugin / src / test / java / org / opendaylight / yangtools / yang2sources / plugin / YangToSourcesProcessorTest.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.yangtools.yang2sources.plugin;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.Mockito.doAnswer;
13
14 import com.google.common.collect.ImmutableTable;
15 import java.io.File;
16 import java.util.List;
17 import java.util.Set;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.opendaylight.yangtools.yang.model.api.Module;
22
23 @RunWith(MockitoJUnitRunner.StrictStubs.class)
24 public class YangToSourcesProcessorTest extends AbstractCodeGeneratorTest {
25     private final File file = new File(getClass().getResource("/yang").getFile());
26
27     @Test
28     public void basicTest() {
29         assertMojoExecution(new YangToSourcesProcessor(file, List.of(),
30             List.of(new FileGeneratorArg("mockGenerator")), project, true,
31             YangProvider.getInstance()), mock -> {
32                 doAnswer(invocation -> {
33                     final Set<Module> localModules = invocation.getArgument(1);
34                     assertEquals(2, localModules.size());
35                     return ImmutableTable.of();
36                 }).when(mock).generateFiles(any(), any(), any());
37             }, mock -> { });
38     }
39
40     @Test
41     public void excludeFilesTest() throws Exception {
42         final File excludedYang = new File(getClass().getResource("/yang/excluded-file.yang").getFile());
43
44         assertMojoExecution(new YangToSourcesProcessor(file, List.of(excludedYang),
45             List.of(new FileGeneratorArg("mockGenerator")), project, true,
46             YangProvider.getInstance()), mock -> {
47                 doAnswer(invocation -> {
48                     final Set<Module> localModules = invocation.getArgument(1);
49                     assertEquals(1, localModules.size());
50                     assertEquals("mock", localModules.iterator().next().getName());
51                     return ImmutableTable.of();
52                 }).when(mock).generateFiles(any(), any(), any());
53             }, mock -> { });
54     }
55 }