### Question:
Initialization extends CoordinateConfiguration { @SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "Applies Maven exception wrapper") public EntryPoint getEntryPoint(ClassLoaderResolver classLoaderResolver, String groupId, String artifactId, String version, String packaging) throws MojoExecutionException { if (entryPoint == null || entryPoint.length() == 0) { throw new MojoExecutionException("Entry point name is not defined"); } for (EntryPoint.Default entryPoint : EntryPoint.Default.values()) { if (this.entryPoint.equals(entryPoint.name())) { return entryPoint; } } try { return (EntryPoint) Class.forName(entryPoint, false, classLoaderResolver.resolve(asCoordinate(groupId, artifactId, version, packaging))) .getDeclaredConstructor() .newInstance(); } catch (Exception exception) { throw new MojoExecutionException("Cannot create entry point: " + entryPoint, exception); } }  static Initialization makeDefault(); @SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "Applies Maven exception wrapper") EntryPoint getEntryPoint(ClassLoaderResolver classLoaderResolver, String groupId, String artifactId, String version, String packaging); public String entryPoint; }### Answer:
@Test public void testRebase() throws Exception { Initialization initialization = new Initialization(); initialization.entryPoint = EntryPoint.Default.REBASE.name(); assertThat(initialization.getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR), is((EntryPoint) EntryPoint.Default.REBASE)); verifyZeroInteractions(classLoaderResolver); }
@Test public void testRedefine() throws Exception { Initialization initialization = new Initialization(); initialization.entryPoint = EntryPoint.Default.REDEFINE.name(); assertThat(initialization.getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR), is((EntryPoint) EntryPoint.Default.REDEFINE)); verifyZeroInteractions(classLoaderResolver); }
@Test public void testRedefineLocal() throws Exception { Initialization initialization = new Initialization(); initialization.entryPoint = EntryPoint.Default.REDEFINE_LOCAL.name(); assertThat(initialization.getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR), is((EntryPoint) EntryPoint.Default.REDEFINE_LOCAL)); verifyZeroInteractions(classLoaderResolver); }
@Test public void testDecorate() throws Exception { Initialization initialization = new Initialization(); initialization.entryPoint = EntryPoint.Default.DECORATE.name(); assertThat(initialization.getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR), is((EntryPoint) EntryPoint.Default.DECORATE)); verifyZeroInteractions(classLoaderResolver); }
@Test public void testCustom() throws Exception { Initialization initialization = new Initialization(); initialization.entryPoint = Foo.class.getName(); when(classLoaderResolver.resolve(new MavenCoordinate(BAR, QUX, BAZ, JAR))).thenReturn(Foo.class.getClassLoader()); assertThat(initialization.getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR), instanceOf(Foo.class)); verify(classLoaderResolver).resolve(new MavenCoordinate(BAR, QUX, BAZ, JAR)); verifyNoMoreInteractions(classLoaderResolver); }
@Test(expected = MojoExecutionException.class) public void testCustomFailed() throws Exception { Initialization initialization = new Initialization(); initialization.entryPoint = FOO; when(classLoaderResolver.resolve(new MavenCoordinate(BAR, QUX, BAZ, JAR))).thenReturn(Foo.class.getClassLoader()); initialization.getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR); }
@Test(expected = MojoExecutionException.class) public void testEmpty() throws Exception { Initialization initialization = new Initialization(); initialization.entryPoint = ""; initialization.getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR); }
@Test(expected = MojoExecutionException.class) public void testNull() throws Exception { new Initialization().getEntryPoint(classLoaderResolver, BAR, QUX, BAZ, JAR); }