Last active
March 2, 2018 22:03
-
-
Save LenarBad/4f6a6c80fd290f646a5ed56e8f1a1f46 to your computer and use it in GitHub Desktop.
Service Client - Usage in Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also
REST API client for TestNG and Spring Boot using Apache Http Components. Part 2