diff --git a/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/NormallyDistributedEndpointDelaySimulation.java b/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/NormallyDistributedEndpointDelaySimulation.java index ea1b276..7198704 100644 --- a/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/NormallyDistributedEndpointDelaySimulation.java +++ b/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/NormallyDistributedEndpointDelaySimulation.java @@ -4,14 +4,13 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.aspectj.lang.annotation.Aspect; -@Aspect @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface NormallyDistributedEndpointDelaySimulation { int mean() default 0; + int standardDeviation() default 0; } diff --git a/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/ProbabilisticEndpointDelaySimulation.java b/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/ProbabilisticEndpointDelaySimulation.java index fce45f3..8d95d62 100644 --- a/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/ProbabilisticEndpointDelaySimulation.java +++ b/commons/src/main/java/at/technikum/masterproject/commons/delay/annotation/ProbabilisticEndpointDelaySimulation.java @@ -4,14 +4,13 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.aspectj.lang.annotation.Aspect; -@Aspect @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface ProbabilisticEndpointDelaySimulation { float probability() default 0; + int delayInMs() default 0; } diff --git a/commons/src/main/java/at/technikum/masterproject/commons/failure/annotation/ProbabilisticFailureSimulation.java b/commons/src/main/java/at/technikum/masterproject/commons/failure/annotation/ProbabilisticFailureSimulation.java index 4425240..cb10986 100644 --- a/commons/src/main/java/at/technikum/masterproject/commons/failure/annotation/ProbabilisticFailureSimulation.java +++ b/commons/src/main/java/at/technikum/masterproject/commons/failure/annotation/ProbabilisticFailureSimulation.java @@ -6,7 +6,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) +@Target({ElementType.METHOD}) public @interface ProbabilisticFailureSimulation { float probability() default 0; diff --git a/customer_service/src/main/java/at/technikum/masterproject/customerservice/customernetwork/CustomerNetworkController.java b/customer_service/src/main/java/at/technikum/masterproject/customerservice/customernetwork/CustomerNetworkController.java index 494a423..f8371d8 100644 --- a/customer_service/src/main/java/at/technikum/masterproject/customerservice/customernetwork/CustomerNetworkController.java +++ b/customer_service/src/main/java/at/technikum/masterproject/customerservice/customernetwork/CustomerNetworkController.java @@ -1,5 +1,6 @@ package at.technikum.masterproject.customerservice.customernetwork; +import at.technikum.masterproject.commons.delay.annotation.NormallyDistributedEndpointDelaySimulation; import at.technikum.masterproject.customerservice.customernetwork.model.domain.CustomerInteraction; import at.technikum.masterproject.customerservice.customernetwork.model.domain.CustomerNetwork; import at.technikum.masterproject.customerservice.customernetwork.model.dto.CustomerInteractionDto; @@ -32,6 +33,7 @@ public CustomerNetworkController( this.customerRelationshipMapper = customerRelationshipMapper; } + @NormallyDistributedEndpointDelaySimulation(mean = 100, standardDeviation = 25) @GetMapping("/{customerId}") public ResponseEntity> getCustomerNetworkForCustomer(@PathVariable int customerId) { List customerNetworks = customerNetworkService.getCustomerNetworksForCustomer(customerId); diff --git a/integration_service/src/main/java/at/technikum/masterproject/integrationservice/model/customer/Gender.java b/integration_service/src/main/java/at/technikum/masterproject/integrationservice/model/customer/Gender.java index a521da4..b55ebbd 100644 --- a/integration_service/src/main/java/at/technikum/masterproject/integrationservice/model/customer/Gender.java +++ b/integration_service/src/main/java/at/technikum/masterproject/integrationservice/model/customer/Gender.java @@ -1,5 +1,22 @@ package at.technikum.masterproject.integrationservice.model.customer; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + public enum Gender { - MALE, FEMALE + MALE, FEMALE; + + @JsonValue + public String encode(){ + return name().toLowerCase(); + } + + @JsonCreator + public static Gender decode(String input){ + try { + return Gender.valueOf(input.toUpperCase()); + } catch (Exception exception) { + throw new IllegalArgumentException("Illegal argument provided for gender, please use male or female."); + } + } } diff --git a/integration_service/src/main/java/at/technikum/masterproject/integrationservice/resolver/dataloader/configuration/ProductDataLoaderConfiguration.java b/integration_service/src/main/java/at/technikum/masterproject/integrationservice/resolver/dataloader/configuration/ProductDataLoaderConfiguration.java index faff3a9..ec1f00f 100644 --- a/integration_service/src/main/java/at/technikum/masterproject/integrationservice/resolver/dataloader/configuration/ProductDataLoaderConfiguration.java +++ b/integration_service/src/main/java/at/technikum/masterproject/integrationservice/resolver/dataloader/configuration/ProductDataLoaderConfiguration.java @@ -49,7 +49,6 @@ private DataLoader> createProductReviewByCustomerDa return DataLoader.newMappedDataLoader(batchLoadFunction); } - private DataLoader createProductInformationDataLoader() { MappedBatchLoader batchLoadFunction = dataLoaderExecutor.generateBatchLoadFunction( productInformationClient::getProductById, Product::getId); diff --git a/integration_service/src/main/resources/application-local.yml b/integration_service/src/main/resources/application-local.yml index 40c116c..d86cf58 100644 --- a/integration_service/src/main/resources/application-local.yml +++ b/integration_service/src/main/resources/application-local.yml @@ -14,7 +14,7 @@ voyager: enabled: true services: - resolver-mode: DATALOADER #DATALOADER, ASYNC or SERIAL + resolver-mode: ASYNC #DATALOADER, ASYNC or SERIAL productservice: authentication-type: BASIC_AUTH url: localhost diff --git a/integration_service/src/main/resources/application.yml b/integration_service/src/main/resources/application.yml index b07d30a..50c658f 100644 --- a/integration_service/src/main/resources/application.yml +++ b/integration_service/src/main/resources/application.yml @@ -11,7 +11,7 @@ graphql: tools: schema-location-pattern: "schemas/**/*.graphqls" servlet: - maxQueryDuration: 12345 + maxQueryDuration: 9999999 maxQueryDepth: 20 #maxQueryComplexity: 10 diff --git a/integration_service/src/main/resources/schemas/schemas.graphqls b/integration_service/src/main/resources/schemas/schemas.graphqls new file mode 100644 index 0000000..3ab0c31 --- /dev/null +++ b/integration_service/src/main/resources/schemas/schemas.graphqls @@ -0,0 +1,4 @@ +schema { + query: Query + mutation: Mutation +} \ No newline at end of file diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/controlleradvice/CommonControllerAdvice.java b/product_service/src/main/java/at/technikum/masterproject/productservice/controlleradvice/CommonControllerAdvice.java index 88ae38d..55256c4 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/controlleradvice/CommonControllerAdvice.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/controlleradvice/CommonControllerAdvice.java @@ -4,11 +4,10 @@ import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; import static org.springframework.http.HttpStatus.NOT_FOUND; -import at.technikum.masterproject.productservice.model.error.ErrorResponse; +import at.technikum.masterproject.commons.responses.ErrorResponse; +import at.technikum.masterproject.commons.responses.ValidationErrorResponse; import at.technikum.masterproject.productservice.productinformation.model.ProductInformationNotFoundException; import at.technikum.masterproject.productservice.productreview.model.ProductReviewNotFoundException; -import java.util.Optional; -import javax.servlet.http.HttpServletRequest; import javax.validation.ValidationException; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; @@ -21,63 +20,52 @@ @Slf4j public class CommonControllerAdvice { - private static final String UUID_ATTRIBUTE = "request-id"; private static final String GENERIC_ERROR_MESSAGE = "An error has occured."; @ExceptionHandler(MethodArgumentNotValidException.class) - ResponseEntity handleMethodArgumentNotValidException(final MethodArgumentNotValidException ex, - final HttpServletRequest request) { + ResponseEntity handleMethodArgumentNotValidException(final MethodArgumentNotValidException ex) { log.warn(ex.getMessage()); return ResponseEntity .status(BAD_REQUEST) - .body(new ErrorResponse(retrieveRequestUuid(request), ex.getMessage())); + .body(ValidationErrorResponse.forException(ex)); } @ExceptionHandler(ValidationException.class) - ResponseEntity handleValidationException(final ValidationException ex, - final HttpServletRequest request) { + ResponseEntity handleValidationException(final ValidationException ex) { log.warn(ex.getMessage()); return ResponseEntity .status(BAD_REQUEST) - .body(new ErrorResponse(retrieveRequestUuid(request), ex.getMessage())); + .body(ErrorResponse.withMessage(ex.getMessage())); } @ExceptionHandler(HttpMessageNotReadableException.class) - ResponseEntity handleMessageNotReadableException(final HttpMessageNotReadableException ex, - final HttpServletRequest request) { + ResponseEntity handleMessageNotReadableException(final HttpMessageNotReadableException ex) { log.warn(ex.getMessage()); return ResponseEntity .status(BAD_REQUEST) - .body(new ErrorResponse(retrieveRequestUuid(request), ex.getMessage())); + .body(ErrorResponse.withMessage(ex.getMessage())); } @ExceptionHandler({ProductInformationNotFoundException.class, ProductReviewNotFoundException.class}) - ResponseEntity handleProductInformationNotFoundException(final ProductInformationNotFoundException ex, - final HttpServletRequest request) { + ResponseEntity handleProductInformationNotFoundException( + final ProductInformationNotFoundException ex) { log.warn(ex.getMessage()); return ResponseEntity .status(NOT_FOUND) - .body(new ErrorResponse(retrieveRequestUuid(request), ex.getMessage())); + .body(ErrorResponse.withMessage(ex.getMessage())); } @ExceptionHandler(Exception.class) - ResponseEntity handleGenericException(final Exception ex, - final HttpServletRequest request) { + ResponseEntity handleGenericException(final Exception ex) { log.warn("Uncaught exception has occurred: {}", ex.getMessage()); return ResponseEntity .status(INTERNAL_SERVER_ERROR) - .body(new ErrorResponse(retrieveRequestUuid(request), GENERIC_ERROR_MESSAGE)); + .body(ErrorResponse.withMessage(GENERIC_ERROR_MESSAGE)); } - private String retrieveRequestUuid(final HttpServletRequest request) { - return Optional.ofNullable(request.getAttribute(UUID_ATTRIBUTE)) - .filter(String.class::isInstance) - .map(String.class::cast) - .orElse("No UUID defined."); - } } diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/model/error/ErrorResponse.java b/product_service/src/main/java/at/technikum/masterproject/productservice/model/error/ErrorResponse.java deleted file mode 100644 index c77f189..0000000 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/model/error/ErrorResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package at.technikum.masterproject.productservice.model.error; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -@Getter -public class ErrorResponse { - - private final String requestUuid; - private final String errorMessage; -} diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationController.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationController.java index 92b4185..fad36c1 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationController.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationController.java @@ -3,7 +3,7 @@ import static org.springframework.http.ResponseEntity.ok; import at.technikum.masterproject.productservice.model.ElementCreationResponse; -import at.technikum.masterproject.productservice.productinformation.model.Product; +import at.technikum.masterproject.productservice.productinformation.model.domain.Product; import at.technikum.masterproject.productservice.productinformation.model.dto.ProductCreationRequest; import at.technikum.masterproject.productservice.productinformation.model.dto.ProductResponse; import at.technikum.masterproject.productservice.productinformation.model.dto.ProductUpdateRequest; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationRepository.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationRepository.java index 16c38ba..dbaf49a 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationRepository.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationRepository.java @@ -1,6 +1,6 @@ package at.technikum.masterproject.productservice.productinformation; -import at.technikum.masterproject.productservice.productinformation.model.Product; +import at.technikum.masterproject.productservice.productinformation.model.domain.Product; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationService.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationService.java index 763b1f2..e15055f 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationService.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/ProductInformationService.java @@ -1,7 +1,7 @@ package at.technikum.masterproject.productservice.productinformation; -import at.technikum.masterproject.productservice.productinformation.model.Product; import at.technikum.masterproject.productservice.productinformation.model.ProductInformationNotFoundException; +import at.technikum.masterproject.productservice.productinformation.model.domain.Product; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/Product.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/domain/Product.java similarity index 97% rename from product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/Product.java rename to product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/domain/Product.java index f10321d..798cb19 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/Product.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/domain/Product.java @@ -1,4 +1,4 @@ -package at.technikum.masterproject.productservice.productinformation.model; +package at.technikum.masterproject.productservice.productinformation.model.domain; import javax.persistence.Embedded; import javax.persistence.Entity; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/ProductDimension.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/domain/ProductDimension.java similarity index 94% rename from product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/ProductDimension.java rename to product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/domain/ProductDimension.java index 869431d..4c25392 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/ProductDimension.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/domain/ProductDimension.java @@ -1,4 +1,4 @@ -package at.technikum.masterproject.productservice.productinformation.model; +package at.technikum.masterproject.productservice.productinformation.model.domain; import javax.persistence.Embeddable; import lombok.Getter; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductDimensionMapper.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductDimensionMapper.java index 50bc400..3c3154e 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductDimensionMapper.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductDimensionMapper.java @@ -1,6 +1,6 @@ package at.technikum.masterproject.productservice.productinformation.model.mapper; -import at.technikum.masterproject.productservice.productinformation.model.ProductDimension; +import at.technikum.masterproject.productservice.productinformation.model.domain.ProductDimension; import at.technikum.masterproject.productservice.productinformation.model.dto.ProductDimensionDto; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductMapper.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductMapper.java index 0da6e28..423fe3c 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductMapper.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productinformation/model/mapper/ProductMapper.java @@ -1,6 +1,6 @@ package at.technikum.masterproject.productservice.productinformation.model.mapper; -import at.technikum.masterproject.productservice.productinformation.model.Product; +import at.technikum.masterproject.productservice.productinformation.model.domain.Product; import at.technikum.masterproject.productservice.productinformation.model.dto.ProductCreationRequest; import at.technikum.masterproject.productservice.productinformation.model.dto.ProductResponse; import at.technikum.masterproject.productservice.productinformation.model.dto.ProductUpdateRequest; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewController.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewController.java index a4d7f65..2e64495 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewController.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewController.java @@ -4,9 +4,9 @@ import at.technikum.masterproject.productservice.model.ElementCreationResponse; import at.technikum.masterproject.productservice.productinformation.ProductInformationService; -import at.technikum.masterproject.productservice.productinformation.model.Product; import at.technikum.masterproject.productservice.productinformation.model.ProductInformationNotFoundException; -import at.technikum.masterproject.productservice.productreview.model.ProductReview; +import at.technikum.masterproject.productservice.productinformation.model.domain.Product; +import at.technikum.masterproject.productservice.productreview.model.domain.ProductReview; import at.technikum.masterproject.productservice.productreview.model.dto.ProductReviewCreationRequest; import at.technikum.masterproject.productservice.productreview.model.dto.ProductReviewResponse; import at.technikum.masterproject.productservice.productreview.model.dto.ProductReviewUpdateRequest; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewRepository.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewRepository.java index d2f673f..4d7d912 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewRepository.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewRepository.java @@ -1,6 +1,6 @@ package at.technikum.masterproject.productservice.productreview; -import at.technikum.masterproject.productservice.productreview.model.ProductReview; +import at.technikum.masterproject.productservice.productreview.model.domain.ProductReview; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewService.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewService.java index b698804..a5220b3 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewService.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/ProductReviewService.java @@ -1,7 +1,7 @@ package at.technikum.masterproject.productservice.productreview; -import at.technikum.masterproject.productservice.productreview.model.ProductReview; import at.technikum.masterproject.productservice.productreview.model.ProductReviewNotFoundException; +import at.technikum.masterproject.productservice.productreview.model.domain.ProductReview; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/ProductReview.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/domain/ProductReview.java similarity index 95% rename from product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/ProductReview.java rename to product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/domain/ProductReview.java index 130a2fe..aad0bd0 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/ProductReview.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/domain/ProductReview.java @@ -1,6 +1,6 @@ -package at.technikum.masterproject.productservice.productreview.model; +package at.technikum.masterproject.productservice.productreview.model.domain; -import at.technikum.masterproject.productservice.productinformation.model.Product; +import at.technikum.masterproject.productservice.productinformation.model.domain.Product; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; diff --git a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/mapper/ProductReviewMapper.java b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/mapper/ProductReviewMapper.java index 7b734bd..d2addb4 100644 --- a/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/mapper/ProductReviewMapper.java +++ b/product_service/src/main/java/at/technikum/masterproject/productservice/productreview/model/mapper/ProductReviewMapper.java @@ -1,6 +1,6 @@ package at.technikum.masterproject.productservice.productreview.model.mapper; -import at.technikum.masterproject.productservice.productreview.model.ProductReview; +import at.technikum.masterproject.productservice.productreview.model.domain.ProductReview; import at.technikum.masterproject.productservice.productreview.model.dto.ProductReviewCreationRequest; import at.technikum.masterproject.productservice.productreview.model.dto.ProductReviewResponse; import at.technikum.masterproject.productservice.productreview.model.dto.ProductReviewUpdateRequest;