### Question:
LlamaException extends Exception { public int getErrorCode() { return errorCode.getCode(); } LlamaException(ErrorCode errorCode, Object... args);  LlamaException(Throwable ex, ErrorCode errorCode, Object... args); int getErrorCode();  }### Answer:
@Test public void testException1() { LlamaException ex = new LlamaException(ErrorCode.TEST); Assert.assertEquals(ErrorCode.TEST.getCode(), ex.getErrorCode()); Assert.assertNull(ex.getCause()); Assert.assertTrue(ex.getMessage().startsWith(ErrorCode.TEST.toString())); }
@Test public void testException2() { LlamaException ex = new LlamaException(ErrorCode.TEST, "a", "b"); Assert.assertEquals(ErrorCode.TEST.getCode(), ex.getErrorCode()); Assert.assertNull(ex.getCause()); Assert.assertTrue(ex.getMessage().startsWith(ErrorCode.TEST.toString())); Assert.assertTrue(ex.getMessage().contains("a:b")); }
@Test public void testException3() { Throwable t = new Throwable(); LlamaException ex = new LlamaException(t, ErrorCode.TEST); Assert.assertEquals(ErrorCode.TEST.getCode(), ex.getErrorCode()); Assert.assertEquals(t, ex.getCause()); Assert.assertTrue(ex.getMessage().startsWith(ErrorCode.TEST.toString())); Assert.assertTrue(ex.getMessage().endsWith(t.toString())); }
@Test public void testException4() { Throwable t = new Throwable(); LlamaException ex = new LlamaException(t, ErrorCode.TEST, "a", "b"); Assert.assertEquals(ErrorCode.TEST.getCode(), ex.getErrorCode()); Assert.assertEquals(t, ex.getCause()); Assert.assertTrue(ex.getMessage().startsWith(ErrorCode.TEST.toString())); Assert.assertTrue(ex.getMessage().endsWith(t.toString())); Assert.assertTrue(ex.getMessage().contains("a:b")); }