Browse Source

Adding testRandomUserSignup integration test

main
ddangelorb 3 years ago
parent
commit
cb7fc3a454
  1. 7
      pom.xml
  2. 23
      src/test/java/org/waterproofingdata/wpdauth/integrationtest/UsersServiceIntegrationTest.java

7
pom.xml

@ -88,6 +88,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>provided</scope>
</dependency>
</dependencies>

23
src/test/java/org/waterproofingdata/wpdauth/integrationtest/UsersServiceIntegrationTest.java

@ -1,5 +1,11 @@
package org.waterproofingdata.wpdauth.integrationtest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.UUID;
import com.google.gson.Gson;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@ -10,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.waterproofingdata.wpdauth.exception.CustomException;
import org.waterproofingdata.wpdauth.model.Roles;
import org.waterproofingdata.wpdauth.model.Users;
import org.waterproofingdata.wpdauth.service.UsersService;
@SpringBootTest
@ -34,4 +42,19 @@ public class UsersServiceIntegrationTest {
String login = usersService.login("admin", "admin");
assertNotNull(login, "Login token returned from usersService.login() should not be null");
}
@Test
public void testRandomUserSignup() {
Users u = new Users();
String uName = String.format("user%s", UUID.randomUUID().toString());
String uEmail = String.format("%s@email.com", uName);
u.setUsername(uName);
u.setPassword(UUID.randomUUID().toString());
u.setEmail(uEmail);
u.setRoles(new ArrayList<Roles>(Arrays.asList(Roles.ROLE_CLIENT)));
String uJson = new Gson().toJson(u);
String signup = usersService.signup(u);
assertNotNull(signup, "Signup token returned from usersService.signup(user) should not be null");
}
}
Loading…
Cancel
Save