From cb7fc3a454daa57c7addbd0cc51c648b8c3d212c Mon Sep 17 00:00:00 2001 From: ddangelorb Date: Fri, 24 Sep 2021 22:01:53 -0300 Subject: [PATCH] Adding testRandomUserSignup integration test --- pom.xml | 7 ++++++ .../UsersServiceIntegrationTest.java | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/pom.xml b/pom.xml index b95d9bb..14a1474 100644 --- a/pom.xml +++ b/pom.xml @@ -88,6 +88,13 @@ org.springframework.boot spring-boot-starter-mail + + + com.google.code.gson + gson + 2.8.5 + provided + diff --git a/src/test/java/org/waterproofingdata/wpdauth/integrationtest/UsersServiceIntegrationTest.java b/src/test/java/org/waterproofingdata/wpdauth/integrationtest/UsersServiceIntegrationTest.java index d929bdd..f4e652b 100644 --- a/src/test/java/org/waterproofingdata/wpdauth/integrationtest/UsersServiceIntegrationTest.java +++ b/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(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"); + } }