Work on #385, added documentation and class diagram. Made refactoring changes to pass checkstyle and PMD checks

This commit is contained in:
Narendra Pathai
2016-03-16 12:40:46 +05:30
parent 7aff77ab27
commit c78dd2667a
8 changed files with 106 additions and 18 deletions

View File

@@ -20,6 +20,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.mute;
import static org.junit.Assert.assertTrue;
@@ -38,6 +39,11 @@ public class MuteTest {
@Rule public ExpectedException exception = ExpectedException.none();
@Test
public void muteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
Mute.mute(() -> methodNotThrowingAnyException());
}
@Test
public void muteShouldRethrowUnexpectedExceptionAsAssertionError() throws Exception {
exception.expect(AssertionError.class);
@@ -46,8 +52,9 @@ public class MuteTest {
Mute.mute(() -> methodThrowingException());
}
private void methodThrowingException() throws Exception {
throw new Exception(MESSAGE);
@Test
public void loggedMuteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
Mute.loggedMute(() -> methodNotThrowingAnyException());
}
@Test
@@ -59,4 +66,13 @@ public class MuteTest {
assertTrue(new String(stream.toByteArray()).contains(MESSAGE));
}
private void methodNotThrowingAnyException() {
System.out.println("Executed successfully");
}
private void methodThrowingException() throws Exception {
throw new Exception(MESSAGE);
}
}