From a874a1de090e0271c81415a8f7d54842a63cbb0b Mon Sep 17 00:00:00 2001 From: Rashidi Zin Date: Sun, 22 Dec 2024 18:52:07 +0800 Subject: [PATCH] Remove redundant code in snippet --- test-slice-tests-rest/README.adoc | 47 ------------------------------- 1 file changed, 47 deletions(-) diff --git a/test-slice-tests-rest/README.adoc b/test-slice-tests-rest/README.adoc index 2b627ba..44bb889 100644 --- a/test-slice-tests-rest/README.adoc +++ b/test-slice-tests-rest/README.adoc @@ -229,53 +229,6 @@ We will implement the same test scenarios as we did in link:{source-test}/user/U [source, java] ---- @Import(TestcontainersConfiguration.class) -@SpringBootTest(webEnvironment = RANDOM_PORT, properties = { - "spring.jpa.hibernate.ddl-auto=create-drop", - "spring.security.user.name=rashidi.zin", - "spring.security.user.password=jU$7d3m0pL3a$eRe|ax" -}) -@Sql(executionPhase = BEFORE_TEST_CLASS, statements = "INSERT INTO users (id, first, last, username, status) VALUES (1, 'Rashidi', 'Zin', 'rashidi.zin', 0)") -class FindByUsernameTests { - - @Autowired - private TestRestTemplate restClient; - - @Test - @DisplayName("Given username rashidi.zin exists When I request for the username Then response status should be OK and it should contain the summary of the user") - void withExistingUsername() { - var response = restClient - .withBasicAuth("rashidi.zin", "jU$7d3m0pL3a$eRe|ax") - .getForEntity("/users/{username}", UserWithoutId.class, "rashidi.zin"); - - assertThat(response.getStatusCode()).isEqualTo(OK); - - var user = response.getBody(); - - assertThat(user) - .extracting("name", "username", "status") - .containsExactly("Rashidi Zin", "rashidi.zin", ACTIVE); - } - - @Test - @DisplayName("Given username zaid.zin does not exist When I request for the username Then response status should be NOT_FOUND") - void withNonExistingUsername() { - var response = restClient - .withBasicAuth("rashidi.zin", "jU$7d3m0pL3a$eRe|ax") - .getForEntity("/users/{username}", UserWithoutId.class, "zaid.zin"); - - assertThat(response.getStatusCode()).isEqualTo(NOT_FOUND); - } - - @Test - @DisplayName("Given there is no authentication When I request for the username Then response status should be UNAUTHORIZED") - void withoutAuthentication() { - var response = restClient.getForEntity("/users/{username}", UserWithoutId.class, "rashidi.zin"); - - assertThat(response.getStatusCode()).isEqualTo(UNAUTHORIZED); - } - -} - @SpringBootTest(webEnvironment = RANDOM_PORT, properties = { "spring.jpa.hibernate.ddl-auto=create-drop", "spring.security.user.name=rashidi.zin",