Skip to content

Instantly share code, notes, and snippets.

@LenarBad
Last active March 2, 2018 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LenarBad/4f6a6c80fd290f646a5ed56e8f1a1f46 to your computer and use it in GitHub Desktop.
Save LenarBad/4f6a6c80fd290f646a5ed56e8f1a1f46 to your computer and use it in GitHub Desktop.
Service Client - Usage in Tests
@SpringBootTest(classes = TestNGWithSpringApplication.class)
public class BookServiceClientExampleIT extends AbstractTestNGSpringContextTests {
@Autowired
BookServiceClient client;
@Test
public void createUpdateDeleteScenarioTest() throws IOException {
Book createdBook = client.createBook(new Book("Title", "Author")).dto();
String id = createdBook.getId();
List<Book> getBooks = client.findBooks().dto();
Book getCreatedBook = getBooks.stream()
.filter(book -> id.equals(book.getId())).findAny().orElse(null);
Book forUpdateBook = new Book("Title1", "Author2");
Book updatedBook = client.updateBook(id, forUpdateBook).dto();
Book getUpdatedBook = client.findBook(id).dto();
client.deleteBook(id);
}
}
@LenarBad
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment