### Question:
StatusProto { public static StatusException toStatusException(com.google.rpc.Status statusProto) { return toStatus(statusProto).asException(toMetadata(statusProto)); } private  StatusProto(); static StatusRuntimeException toStatusRuntimeException(com.google.rpc.Status statusProto); static StatusRuntimeException toStatusRuntimeException(
      com.google.rpc.Status statusProto, Metadata metadata); static StatusException toStatusException(com.google.rpc.Status statusProto); static StatusException toStatusException(
      com.google.rpc.Status statusProto, Metadata metadata); @Nullable static com.google.rpc.Status fromThrowable(Throwable t); @Nullable static com.google.rpc.Status fromStatusAndTrailers(Status status, Metadata trailers);  }### Answer:
@Test public void toStatusException() throws Exception { StatusException se = StatusProto.toStatusException(STATUS_PROTO); com.google.rpc.Status extractedStatusProto = StatusProto.fromThrowable(se); assertEquals(STATUS_PROTO.getCode(), se.getStatus().getCode().value()); assertEquals(STATUS_PROTO.getMessage(), se.getStatus().getDescription()); assertEquals(STATUS_PROTO, extractedStatusProto); }
@Test public void toStatusExceptionWithMetadata_shouldThrowIfMetadataIsNull() throws Exception { try { StatusProto.toStatusException(STATUS_PROTO, null); fail("NullPointerException expected"); } catch (NullPointerException npe) { assertEquals("metadata must not be null", npe.getMessage()); } }
@Test public void toStatusException_shouldThrowIfStatusCodeInvalid() throws Exception { try { StatusProto.toStatusException(INVALID_STATUS_PROTO); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expectedException) { assertEquals("invalid status code", expectedException.getMessage()); } }