From f79c4bd7a1aacd3d1c61177d40af5c4d19de86fe Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 3 Jul 2019 21:54:03 +0200 Subject: [PATCH] #145 [Rights-Module] preparation for module specific roles / static init --- .../hostsharing/hsadminng/HsadminNgApp.java | 4 +++ .../hsadminng/domain/UserRoleAssignment.java | 19 ++++++----- .../accessfilter/JSonAccessFilter.java | 11 ++++--- .../JsonDeserializerWithAccessFilter.java | 14 ++++---- .../JsonSerializerWithAccessFilter.java | 6 ++-- .../hsadminng/service/accessfilter/Role.java | 33 +++++++++++++++---- .../hsadminng/service/dto/AssetDTO.java | 6 ++-- .../hsadminng/service/dto/CustomerDTO.java | 6 ++-- .../hsadminng/service/dto/MembershipDTO.java | 6 ++-- .../hsadminng/service/dto/SepaMandateDTO.java | 6 ++-- .../hsadminng/service/dto/ShareDTO.java | 6 ++-- .../UserRoleAssignmentServiceUnitTest.java | 12 ++++--- .../accessfilter/JSonAccessFilterTest.java | 5 +-- .../JSonAccessFilterTestFixture.java | 9 ++--- ...serializationWithAccessFilterUnitTest.java | 24 +++++++------- ...SerializationWithAccessFilterUnitTest.java | 20 ++++++----- .../service/accessfilter/RoleUnitTest.java | 10 +++--- .../dto/AccessMappingsUnitTestBase.java | 11 ++++--- .../service/dto/AssetDTOIntTest.java | 19 ++++++----- .../service/dto/AssetDTOUnitTest.java | 5 +-- .../service/dto/CustomerDTOUnitTest.java | 14 ++++---- .../service/dto/MembershipDTOIntTest.java | 21 +++++++----- .../service/dto/MembershipDTOUnitTest.java | 5 +-- .../service/dto/SepaMandateDTOIntTest.java | 21 +++++++----- .../service/dto/SepaMandateDTOUnitTest.java | 5 +-- .../service/dto/ShareDTOIntTest.java | 19 ++++++----- .../service/dto/ShareDTOUnitTest.java | 5 +-- .../dto/UserRoleAssignmentUnitTest.java | 16 +++++---- .../web/rest/AssetResourceIntTest.java | 14 ++++---- .../web/rest/ShareResourceIntTest.java | 14 ++++---- .../UserRoleAssignmentResourceIntTest.java | 14 ++++---- 31 files changed, 230 insertions(+), 150 deletions(-) diff --git a/src/main/java/org/hostsharing/hsadminng/HsadminNgApp.java b/src/main/java/org/hostsharing/hsadminng/HsadminNgApp.java index 52e4136f..fcb5e760 100644 --- a/src/main/java/org/hostsharing/hsadminng/HsadminNgApp.java +++ b/src/main/java/org/hostsharing/hsadminng/HsadminNgApp.java @@ -3,6 +3,7 @@ package org.hostsharing.hsadminng; import org.hostsharing.hsadminng.config.ApplicationProperties; import org.hostsharing.hsadminng.config.DefaultProfileUtil; +import org.hostsharing.hsadminng.service.accessfilter.Role; import io.github.jhipster.config.JHipsterConstants; @@ -32,6 +33,9 @@ public class HsadminNgApp { public HsadminNgApp(Environment env) { this.env = env; + + // TODO mhoennig rather use @PostConstruct or something more decentral + Role.init(); } /** diff --git a/src/main/java/org/hostsharing/hsadminng/domain/UserRoleAssignment.java b/src/main/java/org/hostsharing/hsadminng/domain/UserRoleAssignment.java index 2351df19..536feb26 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/UserRoleAssignment.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/UserRoleAssignment.java @@ -1,25 +1,28 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.domain; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.TreeNode; +import static org.hostsharing.hsadminng.service.util.ReflectionUtil.of; + import org.hostsharing.hsadminng.repository.UserRepository; import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.accessfilter.*; import org.hostsharing.hsadminng.service.accessfilter.Role.Admin; import org.hostsharing.hsadminng.service.accessfilter.Role.Supporter; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.TreeNode; + import org.springframework.boot.jackson.JsonComponent; import org.springframework.context.ApplicationContext; +import java.lang.reflect.Field; +import java.util.Objects; + import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.lang.reflect.Field; -import java.util.Objects; - -import static org.hostsharing.hsadminng.service.util.ReflectionUtil.of; /** * A UserRoleAssignment. diff --git a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilter.java b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilter.java index 2e79d807..a765138d 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilter.java +++ b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilter.java @@ -1,12 +1,18 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; +import static com.google.common.base.Verify.verify; +import static com.google.common.collect.Sets.union; +import static java.util.Collections.EMPTY_SET; +import static java.util.Collections.emptySet; + import org.hostsharing.hsadminng.security.SecurityUtils; import org.hostsharing.hsadminng.service.IdToDtoResolver; import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.dto.MembershipDTO; import org.hostsharing.hsadminng.service.util.ReflectionUtil; import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; + import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.security.core.Authentication; @@ -18,11 +24,6 @@ import java.lang.reflect.Field; import java.util.Set; import java.util.stream.Collectors; -import static com.google.common.base.Verify.verify; -import static com.google.common.collect.Sets.union; -import static java.util.Collections.EMPTY_SET; -import static java.util.Collections.emptySet; - abstract class JSonAccessFilter { private final ApplicationContext ctx; diff --git a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonDeserializerWithAccessFilter.java b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonDeserializerWithAccessFilter.java index d4b90c67..afe7dc32 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonDeserializerWithAccessFilter.java +++ b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonDeserializerWithAccessFilter.java @@ -1,6 +1,13 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; +import static com.google.common.base.Verify.verify; +import static org.hostsharing.hsadminng.service.util.ReflectionUtil.unchecked; + +import org.hostsharing.hsadminng.service.UserRoleAssignmentService; +import org.hostsharing.hsadminng.service.util.ReflectionUtil; +import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.databind.DeserializationContext; @@ -8,11 +15,9 @@ import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.*; import com.google.common.base.Joiner; + import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.ObjectUtils; -import org.hostsharing.hsadminng.service.UserRoleAssignmentService; -import org.hostsharing.hsadminng.service.util.ReflectionUtil; -import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; import org.springframework.context.ApplicationContext; import java.lang.reflect.Field; @@ -21,9 +26,6 @@ import java.time.LocalDate; import java.util.HashSet; import java.util.Set; -import static com.google.common.base.Verify.verify; -import static org.hostsharing.hsadminng.service.util.ReflectionUtil.unchecked; - public abstract class JsonDeserializerWithAccessFilter extends JsonDeserializer { private final ApplicationContext ctx; diff --git a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonSerializerWithAccessFilter.java b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonSerializerWithAccessFilter.java index e74f480f..b8849182 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonSerializerWithAccessFilter.java +++ b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JsonSerializerWithAccessFilter.java @@ -1,12 +1,14 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; +import org.hostsharing.hsadminng.service.UserRoleAssignmentService; +import org.hostsharing.hsadminng.service.util.ReflectionUtil; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; + import org.apache.commons.lang3.NotImplementedException; -import org.hostsharing.hsadminng.service.UserRoleAssignmentService; -import org.hostsharing.hsadminng.service.util.ReflectionUtil; import org.springframework.context.ApplicationContext; import java.io.IOException; diff --git a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/Role.java b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/Role.java index 258a34b4..c14cb531 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/Role.java +++ b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/Role.java @@ -1,20 +1,23 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; -import org.apache.commons.lang3.ArrayUtils; +import static com.google.common.base.Verify.verify; +import static org.hostsharing.hsadminng.service.util.ReflectionUtil.initialize; + import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.User; import org.hostsharing.hsadminng.domain.UserRoleAssignment; import org.hostsharing.hsadminng.security.AuthoritiesConstants; import org.hostsharing.hsadminng.service.util.ReflectionUtil; +import org.apache.commons.lang3.ArrayUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; -import static com.google.common.base.Verify.verify; -import static org.hostsharing.hsadminng.service.util.ReflectionUtil.initialize; - /** * These enum values are used to specify the minimum role required to grant access to resources, * see usages of {@link AccessFor}. @@ -33,6 +36,8 @@ import static org.hostsharing.hsadminng.service.util.ReflectionUtil.initialize; */ public abstract class Role { + private static final Logger log = LoggerFactory.getLogger(Role.class); + // TODO mhoennig: We need to make sure that the classes are loaded // and thus the static initializers were called // before these maps are used in production code. @@ -85,10 +90,26 @@ public abstract class Role { T newRole = (T) ReflectionUtil.newInstance(initializedRoleClass); rolesByClass.put(initializedRoleClass, newRole); rolesByName.put(newRole.name(), newRole); + log.info("Role registered: {} as {}", initializedRoleClass, newRole.name()); return newRole; } } + public static void init() { + Role.of(Anybody.class); + Role.of(Hostmaster.class); + Role.of(Admin.class); + Role.of(Supporter.class); + Role.of(AnyCustomerContact.class); + Role.of(CustomerContractualContact.class); + Role.of(CustomerTechnicalContact.class); + Role.of(CustomerFinancialContact.class); + Role.of(AnyCustomerUser.class); + Role.of(ActualCustomerUser.class); + Role.of(Ignored.class); + Role.of(Nobody.class); + } + @Override public String toString() { return getClass().getName() + "(" + name() + ")"; @@ -224,12 +245,12 @@ public abstract class Role { } } - public static class AnyCustomerUser extends DependentRole { + public static class AnyCustomerUser extends IndependentRole { public static final Role ROLE = Role.of(AnyCustomerUser.class); AnyCustomerUser() { - super(Anybody.class); + super(AuthoritiesConstants.USER, Anybody.class); } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java index 54103026..bf88980d 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java @@ -8,16 +8,18 @@ import org.hostsharing.hsadminng.service.MembershipService; import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.accessfilter.*; import org.hostsharing.hsadminng.service.accessfilter.Role.*; + import org.springframework.boot.jackson.JsonComponent; import org.springframework.context.ApplicationContext; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDate; import java.util.Objects; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + /** * A DTO for the Asset entity. */ diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java index 19d6e48b..e4874407 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java @@ -1,20 +1,22 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; +import static org.hostsharing.hsadminng.service.accessfilter.Role.*; + import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; import org.hostsharing.hsadminng.domain.enumeration.VatRegion; import org.hostsharing.hsadminng.service.CustomerService; import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.accessfilter.*; + import org.springframework.boot.jackson.JsonComponent; import org.springframework.context.ApplicationContext; -import javax.validation.constraints.*; import java.time.LocalDate; import java.util.Objects; -import static org.hostsharing.hsadminng.service.accessfilter.Role.*; +import javax.validation.constraints.*; /** * A DTO for the Customer entity. diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java index 75f13277..cbe93fc5 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java @@ -7,14 +7,16 @@ import org.hostsharing.hsadminng.service.MembershipService; import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.accessfilter.*; import org.hostsharing.hsadminng.service.accessfilter.Role.*; + import org.springframework.boot.jackson.JsonComponent; import org.springframework.context.ApplicationContext; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.time.LocalDate; import java.util.Objects; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + /** * A DTO for the Membership entity. */ diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java index 7ff11375..1250b4d8 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java @@ -7,14 +7,16 @@ import org.hostsharing.hsadminng.service.SepaMandateService; import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.accessfilter.*; import org.hostsharing.hsadminng.service.accessfilter.Role.*; + import org.springframework.boot.jackson.JsonComponent; import org.springframework.context.ApplicationContext; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.time.LocalDate; import java.util.Objects; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + /** * A DTO for the SepaMandate entity. */ diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java index 901d3864..39193e90 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java @@ -8,15 +8,17 @@ import org.hostsharing.hsadminng.service.ShareService; import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.accessfilter.*; import org.hostsharing.hsadminng.service.accessfilter.Role.*; + import org.springframework.boot.jackson.JsonComponent; import org.springframework.context.ApplicationContext; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.io.Serializable; import java.time.LocalDate; import java.util.Objects; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + /** * A DTO for the Share entity. */ diff --git a/src/test/java/org/hostsharing/hsadminng/service/UserRoleAssignmentServiceUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/UserRoleAssignmentServiceUnitTest.java index 3b21cbc8..de103658 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/UserRoleAssignmentServiceUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/UserRoleAssignmentServiceUnitTest.java @@ -1,7 +1,10 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service; -import com.google.common.base.VerifyException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.mockito.BDDMockito.given; + import org.hostsharing.hsadminng.domain.UserRoleAssignment; import org.hostsharing.hsadminng.repository.UserRoleAssignmentRepository; import org.hostsharing.hsadminng.service.accessfilter.Role; @@ -9,6 +12,9 @@ import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerContractualCo import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerFinancialContact; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerTechnicalContact; import org.hostsharing.hsadminng.service.accessfilter.SecurityContextFake; + +import com.google.common.base.VerifyException; + import org.junit.Rule; import org.junit.Test; import org.mockito.InjectMocks; @@ -19,10 +25,6 @@ import org.mockito.junit.MockitoRule; import java.util.Arrays; import java.util.Set; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.mockito.BDDMockito.given; - public class UserRoleAssignmentServiceUnitTest { @Rule diff --git a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTest.java b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTest.java index c6f84c4f..dd6a1ba1 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTest.java @@ -1,12 +1,13 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; +import static org.assertj.core.api.Assertions.assertThat; + import org.hostsharing.hsadminng.service.UserRoleAssignmentService; + import org.junit.Test; import org.mockito.Mock; -import static org.assertj.core.api.Assertions.assertThat; - public class JSonAccessFilterTest { @Mock diff --git a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTestFixture.java b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTestFixture.java index 856553b5..ecb9fc02 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTestFixture.java +++ b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonAccessFilterTestFixture.java @@ -1,16 +1,17 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.RandomUtils; +import static org.hostsharing.hsadminng.service.accessfilter.Role.*; + import org.hostsharing.hsadminng.service.IdToDtoResolver; import org.hostsharing.hsadminng.service.dto.FluentBuilder; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; + import java.math.BigDecimal; import java.time.LocalDate; -import static org.hostsharing.hsadminng.service.accessfilter.Role.*; - public class JSonAccessFilterTestFixture { static GivenDto createSampleDto() { diff --git a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonDeserializationWithAccessFilterUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonDeserializationWithAccessFilterUnitTest.java index cdb092e0..6e3ebc56 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonDeserializationWithAccessFilterUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonDeserializationWithAccessFilterUnitTest.java @@ -1,18 +1,27 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.assertj.core.api.Assumptions.assumeThat; +import static org.hostsharing.hsadminng.service.accessfilter.JSonAccessFilterTestFixture.*; +import static org.hostsharing.hsadminng.service.accessfilter.JSonBuilder.asJSon; +import static org.mockito.BDDMockito.given; + +import org.hostsharing.hsadminng.security.AuthoritiesConstants; +import org.hostsharing.hsadminng.service.UserRoleAssignmentService; +import org.hostsharing.hsadminng.service.accessfilter.Role.Admin; +import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.ObjectMapper; + import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.hostsharing.hsadminng.security.AuthoritiesConstants; -import org.hostsharing.hsadminng.service.UserRoleAssignmentService; -import org.hostsharing.hsadminng.service.accessfilter.Role.Admin; -import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -29,13 +38,6 @@ import java.time.LocalDate; import java.util.Arrays; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.assertj.core.api.Assumptions.assumeThat; -import static org.hostsharing.hsadminng.service.accessfilter.JSonAccessFilterTestFixture.*; -import static org.hostsharing.hsadminng.service.accessfilter.JSonBuilder.asJSon; -import static org.mockito.BDDMockito.given; - @SuppressWarnings("ALL") public class JSonDeserializationWithAccessFilterUnitTest { diff --git a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializationWithAccessFilterUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializationWithAccessFilterUnitTest.java index 748dd83c..a7f807b3 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializationWithAccessFilterUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializationWithAccessFilterUnitTest.java @@ -1,9 +1,18 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; -import com.fasterxml.jackson.core.JsonGenerator; -import org.apache.commons.lang3.NotImplementedException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.hostsharing.hsadminng.service.accessfilter.JSonAccessFilterTestFixture.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import org.hostsharing.hsadminng.service.UserRoleAssignmentService; + +import com.fasterxml.jackson.core.JsonGenerator; + +import org.apache.commons.lang3.NotImplementedException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -16,13 +25,6 @@ import org.springframework.context.ApplicationContext; import java.io.IOException; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.hostsharing.hsadminng.service.accessfilter.JSonAccessFilterTestFixture.*; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - public class JSonSerializationWithAccessFilterUnitTest { @Rule diff --git a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/RoleUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/RoleUnitTest.java index abccd5ef..aa080e22 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/accessfilter/RoleUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/accessfilter/RoleUnitTest.java @@ -1,16 +1,18 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.accessfilter; -import com.google.common.base.VerifyException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.ThrowableAssert.catchThrowable; + import org.hostsharing.hsadminng.security.AuthoritiesConstants; import org.hostsharing.hsadminng.service.accessfilter.Role.*; + +import com.google.common.base.VerifyException; + import org.junit.Test; import java.lang.reflect.Field; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.ThrowableAssert.catchThrowable; - public class RoleUnitTest { @Test diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/AccessMappingsUnitTestBase.java b/src/test/java/org/hostsharing/hsadminng/service/dto/AccessMappingsUnitTestBase.java index 5def5068..4d10d2c0 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/AccessMappingsUnitTestBase.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/AccessMappingsUnitTestBase.java @@ -1,9 +1,14 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import org.apache.commons.lang3.RandomUtils; +import static org.apache.commons.lang3.StringUtils.removeEnd; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.fail; + import org.hostsharing.hsadminng.service.accessfilter.*; import org.hostsharing.hsadminng.service.util.ReflectionUtil; + +import org.apache.commons.lang3.RandomUtils; import org.junit.Test; import org.springframework.boot.jackson.JsonComponent; @@ -16,10 +21,6 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; -import static org.apache.commons.lang3.StringUtils.removeEnd; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; - /** * Usually base classes for unit tests are not a good idea, but because * DTOs which implement AccessMapping are more like a DSL, diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOIntTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOIntTest.java index ef843300..1f8d6121 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOIntTest.java @@ -1,9 +1,11 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.RandomUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.junit.Assert.assertEquals; +import static org.mockito.BDDMockito.given; + import org.hostsharing.hsadminng.domain.Asset; import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.Membership; @@ -26,6 +28,11 @@ import org.hostsharing.hsadminng.service.mapper.AssetMapperImpl; import org.hostsharing.hsadminng.service.mapper.CustomerMapperImpl; import org.hostsharing.hsadminng.service.mapper.MembershipMapperImpl; import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.lang3.RandomUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -38,16 +45,12 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit4.SpringRunner; -import javax.persistence.EntityManager; import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDate; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.junit.Assert.assertEquals; -import static org.mockito.BDDMockito.given; +import javax.persistence.EntityManager; @JsonTest @SpringBootTest( diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOUnitTest.java index e025743f..3f71acad 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/AssetDTOUnitTest.java @@ -1,13 +1,14 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.RandomUtils; import org.hostsharing.hsadminng.domain.enumeration.AssetAction; import org.hostsharing.hsadminng.service.accessfilter.Role; import org.hostsharing.hsadminng.service.accessfilter.Role.Admin; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerContractualContact; import org.hostsharing.hsadminng.service.util.RandomUtil; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; import org.junit.Test; import java.math.BigDecimal; diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/CustomerDTOUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/CustomerDTOUnitTest.java index ba1c53a1..b9214af6 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/CustomerDTOUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/CustomerDTOUnitTest.java @@ -1,8 +1,10 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.mockito.BDDMockito.given; + import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; import org.hostsharing.hsadminng.domain.enumeration.VatRegion; @@ -17,6 +19,10 @@ import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerTechnicalCont import org.hostsharing.hsadminng.service.accessfilter.SecurityContextMock; import org.hostsharing.hsadminng.service.mapper.CustomerMapper; import org.hostsharing.hsadminng.service.mapper.CustomerMapperImpl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -32,10 +38,6 @@ import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.mockito.BDDMockito.given; - @JsonTest @SpringBootTest( classes = { diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOIntTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOIntTest.java index e01e6509..3b8ff9a8 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOIntTest.java @@ -1,9 +1,12 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.RandomUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.hostsharing.hsadminng.service.dto.MembershipDTOUnitTest.createSampleDTO; +import static org.junit.Assert.assertEquals; +import static org.mockito.BDDMockito.given; + import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.repository.CustomerRepository; @@ -20,6 +23,11 @@ import org.hostsharing.hsadminng.service.mapper.CustomerMapperImpl; import org.hostsharing.hsadminng.service.mapper.MembershipMapper; import org.hostsharing.hsadminng.service.mapper.MembershipMapperImpl; import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.lang3.RandomUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -32,16 +40,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit4.SpringRunner; -import javax.persistence.EntityManager; import java.io.IOException; import java.util.Objects; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.hostsharing.hsadminng.service.dto.MembershipDTOUnitTest.createSampleDTO; -import static org.junit.Assert.assertEquals; -import static org.mockito.BDDMockito.given; +import javax.persistence.EntityManager; @JsonTest @SpringBootTest( diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOUnitTest.java index 70c25e59..79c21466 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOUnitTest.java @@ -1,13 +1,14 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.RandomUtils; import org.hostsharing.hsadminng.service.accessfilter.Role; import org.hostsharing.hsadminng.service.accessfilter.Role.Admin; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerContractualContact; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerTechnicalContact; import org.hostsharing.hsadminng.service.accessfilter.Role.Supporter; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; import org.junit.Test; import java.time.LocalDate; diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOIntTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOIntTest.java index 7243737a..34807ba1 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOIntTest.java @@ -1,9 +1,12 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.RandomUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.hostsharing.hsadminng.service.dto.SepaMandateDTOUnitTest.createSampleDTO; +import static org.junit.Assert.assertEquals; +import static org.mockito.BDDMockito.given; + import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.SepaMandate; import org.hostsharing.hsadminng.repository.CustomerRepository; @@ -23,6 +26,11 @@ import org.hostsharing.hsadminng.service.mapper.MembershipMapperImpl; import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper; import org.hostsharing.hsadminng.service.mapper.SepaMandateMapperImpl; import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.lang3.RandomUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -35,16 +43,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit4.SpringRunner; -import javax.persistence.EntityManager; import java.io.IOException; import java.util.Objects; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.hostsharing.hsadminng.service.dto.SepaMandateDTOUnitTest.createSampleDTO; -import static org.junit.Assert.assertEquals; -import static org.mockito.BDDMockito.given; +import javax.persistence.EntityManager; @JsonTest @SpringBootTest( diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOUnitTest.java index 56731862..76bd52bd 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTOUnitTest.java @@ -1,13 +1,14 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.RandomUtils; import org.hostsharing.hsadminng.service.accessfilter.Role; import org.hostsharing.hsadminng.service.accessfilter.Role.Admin; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerContractualContact; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerTechnicalContact; import org.hostsharing.hsadminng.service.accessfilter.Role.Supporter; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; import org.junit.Test; import java.time.LocalDate; diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOIntTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOIntTest.java index 26154b42..0948d163 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOIntTest.java @@ -1,9 +1,11 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.RandomUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.junit.Assert.assertEquals; +import static org.mockito.BDDMockito.given; + import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.domain.Share; @@ -25,6 +27,11 @@ import org.hostsharing.hsadminng.service.mapper.MembershipMapperImpl; import org.hostsharing.hsadminng.service.mapper.ShareMapper; import org.hostsharing.hsadminng.service.mapper.ShareMapperImpl; import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.lang3.RandomUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -37,15 +44,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit4.SpringRunner; -import javax.persistence.EntityManager; import java.io.IOException; import java.time.LocalDate; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.junit.Assert.assertEquals; -import static org.mockito.BDDMockito.given; +import javax.persistence.EntityManager; @JsonTest @SpringBootTest( diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOUnitTest.java index c7d9e697..17b79e77 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/ShareDTOUnitTest.java @@ -1,14 +1,15 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.RandomUtils; import org.hostsharing.hsadminng.domain.enumeration.ShareAction; import org.hostsharing.hsadminng.service.accessfilter.Role; import org.hostsharing.hsadminng.service.accessfilter.Role.Admin; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerContractualContact; import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerTechnicalContact; import org.hostsharing.hsadminng.service.util.RandomUtil; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; import org.junit.Test; import java.time.LocalDate; diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/UserRoleAssignmentUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/UserRoleAssignmentUnitTest.java index 7a5dce09..5a22d68d 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/dto/UserRoleAssignmentUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/UserRoleAssignmentUnitTest.java @@ -1,8 +1,11 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.service.dto; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import static org.apache.commons.lang3.tuple.ImmutablePair.of; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.mockito.BDDMockito.given; + import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.User; import org.hostsharing.hsadminng.domain.UserRoleAssignment; @@ -12,6 +15,10 @@ import org.hostsharing.hsadminng.service.UserRoleAssignmentService; import org.hostsharing.hsadminng.service.accessfilter.JSonBuilder; import org.hostsharing.hsadminng.service.accessfilter.Role; import org.hostsharing.hsadminng.service.accessfilter.SecurityContextMock; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -27,11 +34,6 @@ import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; import java.util.Optional; -import static org.apache.commons.lang3.tuple.ImmutablePair.of; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.mockito.BDDMockito.given; - @JsonTest @SpringBootTest( classes = { diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java index ad9d1b43..30849f41 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java @@ -1,6 +1,12 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.web.rest; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.hostsharing.hsadminng.HsadminNgApp; import org.hostsharing.hsadminng.domain.Asset; import org.hostsharing.hsadminng.domain.Membership; @@ -14,6 +20,7 @@ import org.hostsharing.hsadminng.service.accessfilter.SecurityContextMock; import org.hostsharing.hsadminng.service.dto.AssetDTO; import org.hostsharing.hsadminng.service.mapper.AssetMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,18 +37,13 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.Validator; -import javax.persistence.EntityManager; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.ZoneId; import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import javax.persistence.EntityManager; /** * Test class for the AssetResource REST controller. diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java index c049aec9..3feef446 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java @@ -1,6 +1,12 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.web.rest; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.hostsharing.hsadminng.HsadminNgApp; import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.domain.Share; @@ -14,6 +20,7 @@ import org.hostsharing.hsadminng.service.accessfilter.SecurityContextMock; import org.hostsharing.hsadminng.service.dto.ShareDTO; import org.hostsharing.hsadminng.service.mapper.ShareMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,16 +37,11 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.Validator; -import javax.persistence.EntityManager; import java.time.LocalDate; import java.time.ZoneId; import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import javax.persistence.EntityManager; /** * Test class for the ShareResource REST controller. diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/UserRoleAssignmentResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/UserRoleAssignmentResourceIntTest.java index dcd20e1d..cfadadd8 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/UserRoleAssignmentResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/UserRoleAssignmentResourceIntTest.java @@ -1,6 +1,12 @@ // Licensed under Apache-2.0 package org.hostsharing.hsadminng.web.rest; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.hostsharing.hsadminng.HsadminNgApp; import org.hostsharing.hsadminng.domain.User; import org.hostsharing.hsadminng.domain.UserRoleAssignment; @@ -13,6 +19,7 @@ import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerContractualCo import org.hostsharing.hsadminng.service.accessfilter.Role.CustomerTechnicalContact; import org.hostsharing.hsadminng.service.accessfilter.SecurityContextFake; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,14 +35,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.Validator; -import javax.persistence.EntityManager; import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import javax.persistence.EntityManager; /** * Test class for the UserRoleAssignmentResource REST controller.