Remove yang-maven-plugin interfaces
[yangtools.git] / plugin / yang-maven-plugin / src / test / java / org / opendaylight / yangtools / yang2sources / plugin / YangToSourcesMojoTest.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.assertNotNull;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.verify;
13
14 import org.apache.maven.model.Plugin;
15 import org.apache.maven.project.MavenProject;
16 import org.junit.Test;
17 import org.junit.runner.RunWith;
18 import org.mockito.Mock;
19 import org.mockito.Mockito;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.sonatype.plexus.build.incremental.DefaultBuildContext;
22
23 @RunWith(MockitoJUnitRunner.class)
24 public class YangToSourcesMojoTest {
25     @Mock
26     private MavenProject project;
27     @Mock
28     private Plugin plugin;
29
30     @Test
31     public void yangToSourceMojoTest() throws Exception {
32         doReturn(plugin).when(project).getPlugin(YangToSourcesMojo.PLUGIN_NAME);
33
34         YangToSourcesMojo mojo = new YangToSourcesMojo();
35         mojo.setProject(project);
36         mojo.buildContext = new DefaultBuildContext();
37         mojo.execute();
38         assertNotNull(mojo);
39
40         final YangToSourcesProcessor processor = Mockito.mock(YangToSourcesProcessor.class);
41         mojo = new YangToSourcesMojo(processor);
42         mojo.setProject(project);
43         mojo.execute();
44         verify(processor).conditionalExecute(false);
45     }
46 }