Fix constraint violation exception when creating target with whitespaces (#363)
* Added a function to validate if controller id is empty Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Changed how the controller id gets past to other methods Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Changed the way controllderId gets validated in UI and repro - added junit test Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Fixed sonar issue Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Switched to use the RegexpValidator Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
committed by
Michael Hirsch
parent
a57165686e
commit
b30f2bdb1f
@@ -125,6 +125,54 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that a target with whitespaces in controller id cannot be created")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void createTargetWithWhitespaces() {
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(" "));
|
||||
fail("target with whitespaces in controller id should not be created");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(" a"));
|
||||
fail("target with whitespaces in controller id should not be created");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("a "));
|
||||
fail("target with whitespaces in controller id should not be created");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("a b"));
|
||||
fail("target with whitespaces in controller id should not be created");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(" "));
|
||||
fail("target with whitespaces in controller id should not be created");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("aaa bbb"));
|
||||
fail("target with whitespaces in controller id should not be created");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 4),
|
||||
|
||||
Reference in New Issue
Block a user