Skip to content

Commit

Permalink
refactor: add changes to remove PMD issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cake-lier committed Jan 28, 2024
1 parent 67ef8eb commit e1f2640
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,15 @@ private void handleDeleteEntity(final IRI requestIri, final Message<RdfStoreMess
final var artifactIri = requestIri.toString();
final var workspaceIri =
RdfModelUtils.createIri(
Pattern.compile("^(https?://.*?:[0-9]+/workspaces/.*?)/(?:artifacts|agents)/.*?$")
.matcher(artifactIri)
.results()
.map(r -> r.group(1))
.findFirst()
.orElseThrow()
Pattern
.compile(
"^(https?://.*?:[0-9]+/workspaces/.*?)/(?:artifacts|agents)/.*?$"
)
.matcher(artifactIri)
.results()
.map(r -> r.group(1))
.findFirst()
.orElseThrow()
);
this.store
.getEntityModel(workspaceIri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class RdfStoreVerticleCreateTest {
private static final String URIS_EQUAL_MESSAGE = "The URIs should be equal";
private static final String WORKSPACES_PATH = "http://localhost:8080/workspaces/";
private static final String TEST_WORKSPACE_NAME = "test";
private static final String PLATFORM_FILE = "platform_test_td.ttl";
private static final String TEST_WORKSPACE_FILE = "output_test_workspace_td.ttl";

private final BlockingQueue<HttpNotificationDispatcherMessage> notificationQueue;
private RdfStoreMessagebox storeMessagebox;
Expand Down Expand Up @@ -121,12 +123,12 @@ public void testCreateAndGetWorkspace(final VertxTestContext ctx)
throws URISyntaxException, IOException {
final var platformRepresentation =
Files.readString(
Path.of(ClassLoader.getSystemResource("platform_test_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(PLATFORM_FILE).toURI()),
StandardCharsets.UTF_8
);
final var outputWorkspaceRepresentation =
Files.readString(
Path.of(ClassLoader.getSystemResource("output_test_workspace_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(TEST_WORKSPACE_FILE).toURI()),
StandardCharsets.UTF_8
);
this.assertWorkspaceCreated(ctx, outputWorkspaceRepresentation, platformRepresentation)
Expand Down Expand Up @@ -168,11 +170,11 @@ public void testCreateAndGetSubWorkspace(final VertxTestContext ctx)
this.assertWorkspaceCreated(
ctx,
Files.readString(
Path.of(ClassLoader.getSystemResource("output_test_workspace_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(TEST_WORKSPACE_FILE).toURI()),
StandardCharsets.UTF_8
),
Files.readString(
Path.of(ClassLoader.getSystemResource("platform_test_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(PLATFORM_FILE).toURI()),
StandardCharsets.UTF_8
)
)
Expand Down Expand Up @@ -254,11 +256,11 @@ public void testCreateAndGetArtifact(final VertxTestContext ctx)
this.assertWorkspaceCreated(
ctx,
Files.readString(
Path.of(ClassLoader.getSystemResource("output_test_workspace_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(TEST_WORKSPACE_FILE).toURI()),
StandardCharsets.UTF_8
),
Files.readString(
Path.of(ClassLoader.getSystemResource("platform_test_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(PLATFORM_FILE).toURI()),
StandardCharsets.UTF_8
)
)
Expand Down Expand Up @@ -339,11 +341,11 @@ public void testCreateAndGetBody(final VertxTestContext ctx)
this.assertWorkspaceCreated(
ctx,
Files.readString(
Path.of(ClassLoader.getSystemResource("output_test_workspace_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(TEST_WORKSPACE_FILE).toURI()),
StandardCharsets.UTF_8
),
Files.readString(
Path.of(ClassLoader.getSystemResource("platform_test_td.ttl").toURI()),
Path.of(ClassLoader.getSystemResource(PLATFORM_FILE).toURI()),
StandardCharsets.UTF_8
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class RdfStoreVerticleDeleteTest {
private static final String URIS_EQUAL_MESSAGE = "The URIs should be equal";
private static final String PLATFORM_URI = "http://localhost:8080/";
private static final String TEST_WORKSPACE_URI = PLATFORM_URI + "workspaces/test";
private static final String TEST_AGENT_BODY_URI = TEST_WORKSPACE_URI + "/agents/test";
private static final String SUB_WORKSPACE_URI = PLATFORM_URI + "workspaces/sub";
private static final String COUNTER_ARTIFACT_URI = SUB_WORKSPACE_URI + "/artifacts/c0";
private static final String COUNTER_ARTIFACT_FILE = "c0_counter_artifact_sub_td.ttl";
Expand Down Expand Up @@ -157,7 +158,7 @@ public void testDeleteAndGetWorkspace(final VertxTestContext ctx)
bodyDeletionMessage.content()
);
Assertions.assertEquals(
TEST_WORKSPACE_URI + "/agents/test",
TEST_AGENT_BODY_URI,
bodyDeletionMessage.requestIri(),
URIS_EQUAL_MESSAGE
);
Expand Down Expand Up @@ -421,7 +422,7 @@ public void testDeleteAndGetBody(final VertxTestContext ctx)
);
this.assertWorkspaceTreeCreated(ctx)
.compose(r -> this.storeMessagebox.sendMessage(new RdfStoreMessage.DeleteEntity(
TEST_WORKSPACE_URI + "/agents/test"
TEST_AGENT_BODY_URI
)))
.onSuccess(r -> {
RdfStoreVerticleTestHelpers.assertEqualsThingDescriptions(
Expand Down Expand Up @@ -450,7 +451,7 @@ public void testDeleteAndGetBody(final VertxTestContext ctx)
deletionMessage.content()
);
Assertions.assertEquals(
TEST_WORKSPACE_URI + "/agents/test",
TEST_AGENT_BODY_URI,
deletionMessage.requestIri(),
URIS_EQUAL_MESSAGE
);
Expand All @@ -459,7 +460,7 @@ public void testDeleteAndGetBody(final VertxTestContext ctx)
}
})
.compose(r -> this.storeMessagebox.sendMessage(new RdfStoreMessage.GetEntity(
TEST_WORKSPACE_URI + "/agents/test"
TEST_AGENT_BODY_URI
)))
.onFailure(RdfStoreVerticleTestHelpers::assertNotFound)
.recover(r -> this.storeMessagebox.sendMessage(new RdfStoreMessage.GetEntity(
Expand Down

0 comments on commit e1f2640

Please sign in to comment.