コード例 #1
0
  @Test
  public void testValidateValidCollection() {
    List<ContentOverride> overrides = new LinkedList<ContentOverride>();
    overrides.add(new ContentOverride("label", "testname", "value"));
    overrides.add(new ContentOverride("other label", "other name", "other value"));

    validator.validate(overrides);
  }
コード例 #2
0
  @Test
  public void testValidateSingleInvalid() {
    when(config.getBoolean(eq(ConfigProperties.STANDALONE))).thenReturn(false);
    ContentOverride override = new ContentOverride("label", "baseurl", "value");

    try {
      validator.validate(override);
      fail("Expected exception was \"BadRequestException\" not thrown.");
    } catch (BadRequestException bre) {
      assertEquals("Not allowed to override values for: baseurl", bre.getMessage());
    }
  }
コード例 #3
0
  @Test
  public void testValidateCollectionBothInvalid() {
    when(config.getBoolean(eq(ConfigProperties.STANDALONE))).thenReturn(false);
    List<ContentOverride> overrides = new LinkedList<ContentOverride>();
    overrides.add(new ContentOverride("label", "baseurl", "value"));
    overrides.add(new ContentOverride("other label", "name", "other value"));

    try {
      validator.validate(overrides);
      fail("Expected exception \"BadRequestException\" was not thrown.");
    } catch (BadRequestException bre) {
      assertTrue(
          bre.getMessage()
              .matches("^Not allowed to override values for: (?:baseurl, name|name, baseurl)"));
    }
  }
コード例 #4
0
 @Test
 public void testValidateValidOverride() {
   ContentOverride override = new ContentOverride("label", "testname", "value");
   validator.validate(override);
 }