コード例 #1
0
 @Test
 public void shouldNotPassValidationOneRequiredOneOptional1() {
   // given
   SchemaValidationRule rule = new SchemaValidationRule("topElem");
   rule.addMandatoryElements("required");
   rule.addOptionalElements("optional");
   sut = new CommandSchemaValidator(rule);
   Map<String, String> params = new HashMap<String, String>();
   // and
   params.put("topElem", "some value doesn't matter what");
   params.put("optional", "some value doesn't matter what");
   // then
   expectValidationException("[required]", "[optional]");
   sut.validateCommandSchema(params);
 }
コード例 #2
0
 @Parameters({
   "",
   "optional1;optional2;optional3",
   "optional1",
   "optional2",
   "optional3",
   "optional3;optional1",
   "optional2;optional3",
   "optional1;optional3"
 })
 @Test
 public void shouldPassValidationManyRequired(String optionals) {
   // given
   SchemaValidationRule rule = new SchemaValidationRule("topElem");
   rule.addMandatoryElements("required1");
   rule.addMandatoryElements("required2");
   rule.addMandatoryElements("required3");
   rule.addOptionalElements("optional1");
   rule.addOptionalElements("optional2");
   rule.addOptionalElements("optional3");
   sut = new CommandSchemaValidator(rule);
   // and
   Map<String, String> params = new HashMap<String, String>();
   params.put("topElem", "some value doesn't matter what");
   params.put("required1", "some value doesn't matter what");
   params.put("required2", "some value doesn't matter what");
   params.put("required3", "some value doesn't matter what");
   String[] options = optionals.split(";");
   for (String optional : options) {
     if (!optional.isEmpty()) {
       params.put(optional, "some value doesn't matter what");
     }
   }
   // then
   sut.validateCommandSchema(params);
 }
コード例 #3
0
 @Test
 public void shouldPassValidationOneRequiredOneOptional1() {
   // given
   SchemaValidationRule rule = new SchemaValidationRule("topElem");
   rule.addMandatoryElements("required");
   rule.addOptionalElements("optional");
   sut = new CommandSchemaValidator(rule);
   Map<String, String> someMap = new HashMap<String, String>();
   // and
   someMap.put("topElem", "some value doesn't matter what");
   someMap.put("required", "some value doesn't matter what");
   someMap.put("optional", "some value doesn't matter what");
   // when
   sut.validateCommandSchema(someMap);
   // then no exception expected
 }