OpearPackageMojo extends AbstractCommonMojo { String getBundleSymbolicName() { if (OPEAR.equals(project.getPackaging())) { return project.getArtifactId(); } else { return project.getArtifactId() + "-" + OPEAR; } }  @Override void execute(); static final String OPEAR; }
@Test public void testGetBundleSymbolicName() { final OpearPackageMojo mojo = newMojo(); final MavenProject project = mock(MavenProject.class); mojo.project = project; when(project.getArtifactId()).thenReturn("some-artifactId"); when(project.getPackaging()).thenReturn("jar"); assertEquals("expect -opear classifier", "some-artifactId-opear", mojo.getBundleSymbolicName()); when(project.getPackaging()).thenReturn("opear"); assertEquals("expect no classifier", "some-artifactId", mojo.getBundleSymbolicName()); }