PayloadProvider { public <T> T read(Class<T> clazz) { try { return readInternal(clazz); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } if (e instanceof IOException) { throw new UncheckedIOException((IOException) e); } throw new RuntimeException(e); } }  T read(Class<T> clazz);  }
@Test public void dataTest() { when(arguments.getData()) .thenReturn("{\"type\":\"text\",\"text\":\"Hello, World!\"}"); final Message messageRead = target.read(Message.class); assertThat(messageRead) .isEqualTo(TEXT_MESSAGE_EXPECTED); }
@Test public void jsonTest() throws IOException { when(arguments.getJson()) .thenReturn(extractTestResourceAsTempFile("message.json")); final Message messageRead = target.read(Message.class); assertThat(messageRead) .isEqualTo(TEXT_MESSAGE_EXPECTED); }
@Test public void yamlTest() throws IOException { when(arguments.getYaml()) .thenReturn(extractTestResourceAsTempFile("message.yaml")); final Message messageRead = target.read(Message.class); assertThat(messageRead) .isEqualTo(TEXT_MESSAGE_EXPECTED); }
@Test public void unsetPropertyExceptionTest() { assertThatThrownBy(() -> { target.read(Message.class); }).isInstanceOf(IllegalArgumentException.class); }