@Test
 public void testRequiredTypeIsMissing() throws Exception {
   expectedException.expect(IllegalArgumentException.class);
   expectedException.expectMessage(
       "The following required parameters are missing to create a repository of type \"fs\": [location]");
   validator.validate("fs", ImmutableSettings.EMPTY);
 }
 @Test
 public void testInvalidSetting() throws Exception {
   expectedException.expect(IllegalArgumentException.class);
   expectedException.expectMessage("Invalid parameters specified: [yay]");
   Settings settings =
       ImmutableSettings.builder().put("location", "foo").put("yay", "invalid").build();
   validator.validate("fs", settings);
 }
Ejemplo n.º 3
0
  @Override
  public CreateRepositoryAnalyzedStatement visitCreateRepository(
      CreateRepository node, Analysis context) {
    String repositoryName = node.repository();
    if (repositoryService.getRepository(repositoryName) != null) {
      throw new RepositoryAlreadyExistsException(repositoryName);
    }

    Settings settings = ImmutableSettings.EMPTY;
    if (node.properties().isPresent()) {
      settings =
          GenericPropertiesConverter.genericPropertiesToSettings(
              node.properties().get(), context.parameterContext());
    }
    repositoryParamValidator.validate(node.type(), settings);
    return new CreateRepositoryAnalyzedStatement(repositoryName, node.type(), settings);
  }
 @Test
 public void testHdfsDynamicConfParam() throws Exception {
   Settings settings =
       ImmutableSettings.builder().put("path", "/data").put("conf.foobar", "bar").build();
   validator.validate("hdfs", settings);
 }
 @Test
 public void testValidate() throws Exception {
   expectedException.expect(IllegalArgumentException.class);
   expectedException.expectMessage("Invalid repository type \"invalid_type\"");
   validator.validate("invalid_type", ImmutableSettings.EMPTY);
 }