コード例 #1
0
 @Test
 public void shouldNotCreatePackageRepositoryIfTheSpecifiedPluginTypeIsInvalid() throws Exception {
   when(packageRepositoryService.validatePluginId(packageRepository)).thenReturn(false);
   when(packageRepositoryService.validateRepositoryConfiguration(packageRepository))
       .thenReturn(true);
   CreatePackageRepositoryCommand command =
       new CreatePackageRepositoryCommand(
           goConfigService, packageRepositoryService, packageRepository, currentUser, result);
   assertFalse(command.isValid(cruiseConfig));
 }
コード例 #2
0
 @Test
 public void shouldNotCreatePackageRepositoryWhenRepositoryWithSpecifiedNameAlreadyExists()
     throws Exception {
   CreatePackageRepositoryCommand command =
       new CreatePackageRepositoryCommand(
           goConfigService, packageRepositoryService, packageRepository, currentUser, result);
   command.update(cruiseConfig);
   assertFalse(command.isValid(cruiseConfig));
   assertThat(
       packageRepository.errors().firstError(),
       is(
           "You have defined multiple repositories called 'npmOrg'. Repository names are case-insensitive and must be unique."));
 }
コード例 #3
0
  @Test
  public void shouldNotCreatePackageRepositoryWhenRepositoryHasInvalidName() throws Exception {
    packageRepository.setName("~!@#$%^&*(");
    CreatePackageRepositoryCommand command =
        new CreatePackageRepositoryCommand(
            goConfigService, packageRepositoryService, packageRepository, currentUser, result);

    assertFalse(command.isValid(cruiseConfig));
    assertThat(
        packageRepository.errors().firstError(),
        is(
            "Invalid PackageRepository name '~!@#$%^&*('. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
  }
コード例 #4
0
 @Test
 public void shouldNotCreatePackageRepositoryWhenRepositoryHasDuplicateConfigurationProperties()
     throws Exception {
   ConfigurationProperty property =
       new ConfigurationProperty(new ConfigurationKey("foo"), new ConfigurationValue("bar"));
   Configuration configuration = new Configuration(property, property);
   packageRepository.setConfiguration(configuration);
   CreatePackageRepositoryCommand command =
       new CreatePackageRepositoryCommand(
           goConfigService, packageRepositoryService, packageRepository, currentUser, result);
   assertFalse(command.isValid(cruiseConfig));
   assertThat(
       property.errors().firstError(), is("Duplicate key 'foo' found for Repository 'npmOrg'"));
 }