Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended AddedEntityBinding/RemovedEntityBinding event ids with granularity #1797

Merged
merged 2 commits into from
Jun 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Slightly changed the event id wording
rchache committed Jun 8, 2023
commit 978bfaf72902b92aaf968a2f380ff9287f60a2f4
Original file line number Diff line number Diff line change
@@ -38,8 +38,8 @@
public final class AddedEntityBinding extends AbstractDiffEvaluator {
private static final String ADDED_RESOURCE = "AddedResourceBinding";
private static final String ADDED_OPERATION = "AddedOperationBinding";
private static final String TO_RESOURCE = ".ToResourceAdded.";
private static final String TO_SERVICE = ".ToServiceAdded.";
private static final String TO_RESOURCE = ".ToResource.";
private static final String TO_SERVICE = ".ToService.";

@Override
public List<ValidationEvent> evaluate(Differences differences) {
@@ -69,7 +69,7 @@ private ValidationEvent createAddedEvent(String typeOfAddition, EntityShape pare
"%s binding of `%s` was added to the %s shape, `%s`",
childType, childShape, parentEntity.getType(), parentEntity.getId());
return ValidationEvent.builder()
.id(typeOfAddition + typeOfParentShape + childShape)
.id(typeOfAddition + typeOfParentShape + childShape.getName())
.severity(Severity.NOTE)
.shape(parentEntity)
.message(message)
Original file line number Diff line number Diff line change
@@ -38,8 +38,8 @@
public final class RemovedEntityBinding extends AbstractDiffEvaluator {
private static final String REMOVED_RESOURCE = "RemovedResourceBinding";
private static final String REMOVED_OPERATION = "RemovedOperationBinding";
private static final String FROM_RESOURCE = ".FromResourceRemoved.";
private static final String FROM_SERVICE = ".FromServiceRemoved.";
private static final String FROM_RESOURCE = ".FromResource.";
private static final String FROM_SERVICE = ".FromService.";

@Override
public List<ValidationEvent> evaluate(Differences differences) {
@@ -69,7 +69,7 @@ private ValidationEvent createRemovedEvent(String typeOfRemoval, EntityShape par
"%s binding of `%s` was removed from %s shape, `%s`",
childType, childShape, parentEntity.getType(), parentEntity.getId());
return ValidationEvent.builder()
.id(typeOfRemoval + typeOfParentShape + childShape)
.id(typeOfRemoval + typeOfParentShape + childShape.getName())
.severity(Severity.ERROR)
.shape(parentEntity)
.message(message)
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public void detectsAddedOperationToService() {
Model modelB = Model.assembler().addShapes(service1, o).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "AddedOperationBinding.ToServiceAdded.foo.baz#Operation").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "AddedOperationBinding.ToService.Operation").size(), equalTo(1));
}

@Test
@@ -53,7 +53,7 @@ public void detectsAddedOperationToResource() {
Model modelB = Model.assembler().addShapes(r1, o).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "AddedOperationBinding.ToResourceAdded.foo.baz#Operation").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "AddedOperationBinding.ToResource.Operation").size(), equalTo(1));
}

@Test
@@ -69,7 +69,7 @@ public void detectsAddedResourceToService() {
Model modelB = Model.assembler().addShapes(service1, r).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "AddedResourceBinding.ToServiceAdded.foo.baz#Resource").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "AddedResourceBinding.ToService.Resource").size(), equalTo(1));
}

@Test
@@ -81,6 +81,6 @@ public void detectsAddedResourceToResource() {
Model modelB = Model.assembler().addShapes(p1, child).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "AddedResourceBinding.ToResourceAdded.foo.baz#C").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "AddedResourceBinding.ToResource.C").size(), equalTo(1));
}
}
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public void detectsRemovedOperationFromService() {
Model modelB = Model.assembler().addShapes(service2, o).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "RemovedOperationBinding.FromServiceRemoved.foo.baz#Operation").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "RemovedOperationBinding.FromService.Operation").size(), equalTo(1));
}

@Test
@@ -53,7 +53,7 @@ public void detectsRemovedOperationFromResource() {
Model modelB = Model.assembler().addShapes(r2, o).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "RemovedOperationBinding.FromResourceRemoved.foo.baz#Operation").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "RemovedOperationBinding.FromResource.Operation").size(), equalTo(1));
}

@Test
@@ -69,7 +69,7 @@ public void detectsRemovedResourceFromService() {
Model modelB = Model.assembler().addShapes(service2, r).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "RemovedResourceBinding.FromServiceRemoved.foo.baz#Resource").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "RemovedResourceBinding.FromService.Resource").size(), equalTo(1));
}

@Test
@@ -81,6 +81,6 @@ public void detectsRemovedResourceFromResource() {
Model modelB = Model.assembler().addShapes(p2, child).assemble().unwrap();
List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

assertThat(TestHelper.findEvents(events, "RemovedResourceBinding.FromResourceRemoved.foo.baz#C").size(), equalTo(1));
assertThat(TestHelper.findEvents(events, "RemovedResourceBinding.FromResource.C").size(), equalTo(1));
}
}