Skip to content

Commit

Permalink
MODTLR-10 Fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrVidinieiev committed Jan 25, 2024
1 parent 0466b9f commit 8ceecac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.folio.exception;

public class TenantScopedExecutionException extends RuntimeException {
private final String tenantId;

public TenantScopedExecutionException(Exception cause, String tenantId) {
super(cause);
this.tenantId = tenantId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Map;
import java.util.concurrent.Callable;

import org.folio.exception.TenantScopedExecutionException;
import org.folio.service.TenantScopedExecutionService;
import org.folio.spring.FolioExecutionContext;
import org.folio.spring.FolioModuleMetadata;
Expand Down Expand Up @@ -33,7 +34,7 @@ public <T> T execute(String tenantId, Callable<T> action) {
return action.call();
} catch (Exception e) {
log.error("execute:: tenantId={}", tenantId, e);
throw new RuntimeException(e);
throw new TenantScopedExecutionException(e, tenantId);
}
}
}
6 changes: 3 additions & 3 deletions src/test/java/org/folio/api/EcsTlrApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ void getByIdNotFound() throws Exception {
}

@Test
public void titleLevelRequestIsCreatedForDifferentTenant() {
void titleLevelRequestIsCreatedForDifferentTenant() {
EcsTlr ecsTlr = buildEcsTlr();
wireMockServer.stubFor(WireMock.post(urlMatching(".*/circulation/requests"))
.withHeader(TENANT_HEADER, equalTo(ANOTHER_TENANT))
.willReturn(jsonResponse(asJsonString(ecsTlr), HttpStatus.SC_CREATED)));
assertEquals(getCurrentTenantId(), TENANT);
assertEquals(TENANT, getCurrentTenantId());

doPost(TLR_URL, ecsTlr)
.expectStatus().isCreated()
.expectBody().json(asJsonString(ecsTlr));

assertEquals(getCurrentTenantId(), TENANT);
assertEquals(TENANT, getCurrentTenantId());
wireMockServer.verify(postRequestedFor(urlMatching(".*/circulation/requests"))
.withHeader(TENANT_HEADER, equalTo(ANOTHER_TENANT)));
}
Expand Down

0 comments on commit 8ceecac

Please sign in to comment.