diff --git a/src/main/java/org/prebid/cache/handlers/storage/PostStorageHandler.java b/src/main/java/org/prebid/cache/handlers/storage/PostStorageHandler.java index 052552c..a41c832 100644 --- a/src/main/java/org/prebid/cache/handlers/storage/PostStorageHandler.java +++ b/src/main/java/org/prebid/cache/handlers/storage/PostStorageHandler.java @@ -7,7 +7,7 @@ import org.prebid.cache.builders.PrebidServerResponseBuilder; import org.prebid.cache.config.StorageConfig; import org.prebid.cache.exceptions.BadRequestException; -import org.prebid.cache.model.ModulePayload; +import org.prebid.cache.model.StoragePayload; import org.prebid.cache.model.Payload; import org.prebid.cache.model.PayloadWrapper; import org.prebid.cache.repository.redis.module.storage.ModuleCompositeRepository; @@ -42,12 +42,12 @@ public Mono save(final ServerRequest request) { return ServerResponse.status(HttpStatus.UNAUTHORIZED).build(); } - return request.body(BodyExtractors.toMono(ModulePayload.class)) + return request.body(BodyExtractors.toMono(StoragePayload.class)) .switchIfEmpty(Mono.error(new BadRequestException("Empty body"))) .handle(this::validateModulePayload) - .flatMap(modulePayload -> moduleRepository.save( - modulePayload.getApplication(), - mapToPayloadWrapper(modulePayload))) + .flatMap(storagePayload -> moduleRepository.save( + storagePayload.getApplication(), + mapToPayloadWrapper(storagePayload))) .subscribeOn(Schedulers.parallel()) .flatMap(ignored -> ServerResponse.noContent().build()) .onErrorResume(error -> responseBuilder.error(Mono.just(error), request)); @@ -57,7 +57,7 @@ private boolean isApiKeyValid(final ServerRequest request) { return StringUtils.equals(request.headers().firstHeader(API_KEY_HEADER), apiConfig.getApiKey()); } - private void validateModulePayload(final ModulePayload payload, final SynchronousSink sink) { + private void validateModulePayload(final StoragePayload payload, final SynchronousSink sink) { final var result = validator.validate(payload); if (result.isEmpty()) { sink.next(payload); @@ -69,7 +69,7 @@ private void validateModulePayload(final ModulePayload payload, final Synchronou } } - private PayloadWrapper mapToPayloadWrapper(final ModulePayload payload) { + private PayloadWrapper mapToPayloadWrapper(final StoragePayload payload) { final long ttlSeconds = Optional.ofNullable(payload.getTtlseconds()) .map(Integer::longValue) .orElse(storageConfig.getDefaultTtlSeconds()); diff --git a/src/main/java/org/prebid/cache/model/ModulePayload.java b/src/main/java/org/prebid/cache/model/StoragePayload.java similarity index 94% rename from src/main/java/org/prebid/cache/model/ModulePayload.java rename to src/main/java/org/prebid/cache/model/StoragePayload.java index 47177a6..a9d7e61 100644 --- a/src/main/java/org/prebid/cache/model/ModulePayload.java +++ b/src/main/java/org/prebid/cache/model/StoragePayload.java @@ -9,7 +9,7 @@ @Value @Builder -public class ModulePayload { +public class StoragePayload { @NotEmpty public String key; diff --git a/src/test/java/org/prebid/cache/handlers/PostStorageHandlerTests.java b/src/test/java/org/prebid/cache/handlers/PostStorageHandlerTests.java index 3b967e5..08b2753 100644 --- a/src/test/java/org/prebid/cache/handlers/PostStorageHandlerTests.java +++ b/src/test/java/org/prebid/cache/handlers/PostStorageHandlerTests.java @@ -9,7 +9,7 @@ import org.prebid.cache.builders.PrebidServerResponseBuilder; import org.prebid.cache.config.StorageConfig; import org.prebid.cache.handlers.storage.PostStorageHandler; -import org.prebid.cache.model.ModulePayload; +import org.prebid.cache.model.StoragePayload; import org.prebid.cache.model.Payload; import org.prebid.cache.model.PayloadWrapper; import org.prebid.cache.repository.redis.module.storage.ModuleCompositeRepository; @@ -78,7 +78,7 @@ public void teardown() { void testVerifySave() { given(validator.validate(any())).willReturn(Collections.emptySet()); - final var payload = ModulePayload.builder() + final var payload = StoragePayload.builder() .key("key") .type(PayloadType.TEXT) .application("application") @@ -113,7 +113,7 @@ void testVerifySave() { void testVerifyApiKeyAuthorization() { given(validator.validate(any())).willReturn(Collections.emptySet()); - final var payload = ModulePayload.builder() + final var payload = StoragePayload.builder() .key("key") .type(PayloadType.TEXT) .application("application")