Skip to content

Commit

Permalink
feat:
Browse files Browse the repository at this point in the history
Run mvn spotless:apply
  • Loading branch information
Leandro13Silva13 committed Mar 22, 2024
1 parent b7c37db commit e951904
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +1,37 @@
package de.caritas.cob.userservice.api.adapters.web.controller;

import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.ADMIN_DATA_PATH;
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.AGENCY_ADMIN_PATH;
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.CONSULTANT_PATH;
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.TENANT_ADMIN_PATH;
import static de.caritas.cob.userservice.api.adapters.web.controller.UserAdminControllerIT.TENANT_ADMIN_PATH_WITHOUT_SLASH;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
import de.caritas.cob.userservice.api.adapters.keycloak.dto.KeycloakCreateUserResponseDTO;
import de.caritas.cob.userservice.api.adapters.rocketchat.RocketChatCredentialsProvider;
import de.caritas.cob.userservice.api.adapters.web.dto.CreateAdminDTO;
import de.caritas.cob.userservice.api.adapters.web.dto.CreateConsultantDTO;
import de.caritas.cob.userservice.api.adapters.web.dto.PatchAdminDTO;
import de.caritas.cob.userservice.api.adapters.web.dto.UpdateAgencyAdminDTO;
import de.caritas.cob.userservice.api.adapters.web.dto.UpdateTenantAdminDTO;
import de.caritas.cob.userservice.api.admin.service.tenant.TenantService;
import de.caritas.cob.userservice.api.config.apiclient.AgencyServiceApiControllerFactory;
import de.caritas.cob.userservice.api.config.apiclient.ConsultingTypeServiceApiControllerFactory;
import de.caritas.cob.userservice.api.config.apiclient.MailServiceApiControllerFactory;
import de.caritas.cob.userservice.api.config.auth.Authority.AuthorityValue;
import de.caritas.cob.userservice.api.config.auth.IdentityConfig;
import de.caritas.cob.userservice.api.helper.AuthenticatedUser;
import de.caritas.cob.userservice.api.model.Admin.AdminType;
import de.caritas.cob.userservice.api.model.User;
import de.caritas.cob.userservice.api.port.out.AdminRepository;
import de.caritas.cob.userservice.api.port.out.IdentityClient;
import de.caritas.cob.userservice.api.tenant.TenantResolverService;
import de.caritas.cob.userservice.api.testConfig.TestAgencyControllerApi;
import de.caritas.cob.userservice.consultingtypeservice.generated.web.ConsultingTypeControllerApi;
import de.caritas.cob.userservice.mailservice.generated.web.MailsControllerApi;
import de.caritas.cob.userservice.tenantservice.generated.web.model.RestrictedTenantDTO;
import de.caritas.cob.userservice.topicservice.generated.web.TopicControllerApi;
import java.util.LinkedHashMap;
import javax.servlet.http.Cookie;
import net.minidev.json.JSONArray;
import org.jeasy.random.EasyRandom;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.keycloak.admin.client.Keycloak;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -69,7 +46,6 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

@SpringBootTest
@AutoConfigureMockMvc
Expand Down Expand Up @@ -107,11 +83,9 @@ class UserAdminControllerMultiTenancyTrueE2EIT {

@MockBean TenantService tenantService;

@MockBean
TenantResolverService tenantResolverService;
@MockBean TenantResolverService tenantResolverService;

@MockBean
AuthenticatedUser authenticatedUser;
@MockBean AuthenticatedUser authenticatedUser;

@AfterEach
void reset() {
Expand Down Expand Up @@ -169,8 +143,7 @@ void createNewAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGiven(

@Test
@WithMockUser(authorities = {AuthorityValue.USER_ADMIN})
void createNewAgencyAdmin_Should_return500_When_superAdminHasNullTenantID()
throws Exception {
void createNewAgencyAdmin_Should_return500_When_superAdminHasNullTenantID() throws Exception {
// given
CreateAdminDTO createAdminDTO = new EasyRandom().nextObject(CreateAdminDTO.class);
createAdminDTO.setEmail("[email protected]");
Expand All @@ -197,38 +170,7 @@ private void givenTenantSuperAdmin() {

private void givenTenant() {
when(tenantResolverService.resolve(any())).thenReturn(95L);
when(tenantService.getRestrictedTenantData(anyLong())).thenReturn(new RestrictedTenantDTO().subdomain("subdomain"));
when(tenantService.getRestrictedTenantData(anyLong()))
.thenReturn(new RestrictedTenantDTO().subdomain("subdomain"));
}
}
































Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void afterTests() {

@Test
public void
createNewAdminAgency_Should_returnExpectedCreatedAdmin_When_userIsSuperAdminAndInputDataIsCorrectAndMultitenancyDisabled() {
createNewAdminAgency_Should_returnExpectedCreatedAdmin_When_userIsSuperAdminAndInputDataIsCorrectAndMultitenancyDisabled() {
// given
ReflectionTestUtils.setField(createAdminService, "multiTenancyEnabled", false);
TenantContext.setCurrentTenant(0L);
Expand Down

0 comments on commit e951904

Please sign in to comment.