Skip to content

Commit

Permalink
Core: Fix naming for storage service (#3374)
Browse files Browse the repository at this point in the history
  • Loading branch information
SerhiiNahornyi authored Aug 12, 2024
1 parent c1bd6fb commit ef313c0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ public Future<Void> storeEntry(String key,
StorageDataType type,
Integer ttlseconds,
String application,
String moduleCode) {
String appCode) {

try {
validateStoreData(key, value, application, type, moduleCode);
validateStoreData(key, value, application, type, appCode);
} catch (PreBidException e) {
return Future.failedFuture(e);
}

final ModuleCacheRequest moduleCacheRequest =
ModuleCacheRequest.of(
constructEntryKey(key, moduleCode),
constructEntryKey(key, appCode),
type,
prepareValueForStoring(value, type),
application,
Expand Down Expand Up @@ -124,18 +124,18 @@ private Future<Void> processStoreResponse(int statusCode, String responseBody) {
}

@Override
public Future<ModuleCacheResponse> retrieveModuleEntry(String key,
String moduleCode,
String application) {
public Future<ModuleCacheResponse> retrieveEntry(String key,
String appCode,
String application) {

try {
validateRetrieveData(key, application, moduleCode);
validateRetrieveData(key, application, appCode);
} catch (PreBidException e) {
return Future.failedFuture(e);
}

return httpClient.get(
getRetrieveEndpoint(key, moduleCode, application),
getRetrieveEndpoint(key, appCode, application),
securedCallHeaders(),
callTimeoutMs)
.map(response -> toModuleCacheResponse(response.getStatusCode(), response.getBody()));
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/prebid/server/cache/PbcStorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Future<Void> storeEntry(String key,
StorageDataType type,
Integer ttlseconds,
String application,
String moduleCode);
String appCode);

Future<ModuleCacheResponse> retrieveModuleEntry(String key, String moduleCode, String application);
Future<ModuleCacheResponse> retrieveEntry(String key, String appCode, String application);

static NoOpPbcStorageService noOp() {
return new NoOpPbcStorageService();
Expand All @@ -27,13 +27,13 @@ public Future<Void> storeEntry(String key,
StorageDataType type,
Integer ttlseconds,
String application,
String moduleCode) {
String appCode) {

return Future.succeededFuture();
}

@Override
public Future<ModuleCacheResponse> retrieveModuleEntry(String key, String moduleCode, String application) {
public Future<ModuleCacheResponse> retrieveEntry(String key, String appCode, String application) {
return Future.succeededFuture(ModuleCacheResponse.empty());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ public void storeEntryShouldCreateCallWithApiKeyInHeader() {
}

@Test
public void retrieveModuleEntryShouldReturnFailedFutureIfModuleKeyIsMissed() {
public void retrieveModuleEntryShouldReturnFailedFutureIfKeyIsMissed() {
// when
final Future<ModuleCacheResponse> result =
target.retrieveModuleEntry(null, "some-module-code", "some-app");
target.retrieveEntry(null, "some-module-code", "some-app");

// then
assertThat(result.failed()).isTrue();
Expand All @@ -237,10 +237,10 @@ public void retrieveModuleEntryShouldReturnFailedFutureIfModuleKeyIsMissed() {
}

@Test
public void retrieveModuleEntryShouldReturnFailedFutureIfModuleApplicationIsMissed() {
public void retrieveModuleEntryShouldReturnFailedFutureIfApplicationIsMissed() {
// when
final Future<ModuleCacheResponse> result =
target.retrieveModuleEntry("some-key", "some-module-code", null);
target.retrieveEntry("some-key", "some-module-code", null);

// then
assertThat(result.failed()).isTrue();
Expand All @@ -249,10 +249,10 @@ public void retrieveModuleEntryShouldReturnFailedFutureIfModuleApplicationIsMiss
}

@Test
public void retrieveModuleEntryShouldReturnFailedFutureIfModuleCodeIsMissed() {
public void retrieveModuleEntryShouldReturnFailedFutureIfCodeIsMissed() {
// when
final Future<ModuleCacheResponse> result =
target.retrieveModuleEntry("some-key", null, "some-app");
target.retrieveEntry("some-key", null, "some-app");

// then
assertThat(result.failed()).isTrue();
Expand All @@ -261,19 +261,19 @@ public void retrieveModuleEntryShouldReturnFailedFutureIfModuleCodeIsMissed() {
}

@Test
public void retrieveModuleEntryShouldCreateCallWithApiKeyInHeader() {
public void retrieveEntryShouldCreateCallWithApiKeyInHeader() {
// when
target.retrieveModuleEntry("some-key", "some-module-code", "some-app");
target.retrieveEntry("some-key", "some-module-code", "some-app");

// then
final MultiMap result = captureRetrieveRequestHeaders();
assertThat(result.get(HttpUtil.X_PBC_API_KEY_HEADER)).isEqualTo("pbc-api-key");
}

@Test
public void retrieveModuleEntryShouldCreateCallWithKeyInParams() {
public void retrieveEntryShouldCreateCallWithKeyInParams() {
// when
target.retrieveModuleEntry("some-key", "some-module-code", "some-app");
target.retrieveEntry("some-key", "some-module-code", "some-app");

// then
final String result = captureRetrieveUrl();
Expand All @@ -282,10 +282,10 @@ public void retrieveModuleEntryShouldCreateCallWithKeyInParams() {
}

@Test
public void retrieveModuleEntryShouldReturnExpectedResponse() {
public void retrieveEntryShouldReturnExpectedResponse() {
// when
final Future<ModuleCacheResponse> result =
target.retrieveModuleEntry("some-key", "some-module-code", "some-app");
target.retrieveEntry("some-key", "some-module-code", "some-app");

// then
assertThat(result.result())
Expand Down

0 comments on commit ef313c0

Please sign in to comment.