@Test public void shouldValidateArtifactStoreIdPattern() { ArtifactStore store = new ArtifactStore("!123", "docker"); store.validate(null); assertThat(store.errors().size(), is(1)); assertThat(store.errors().on(ArtifactStore.ID), is("Invalid id '!123'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters.")); }
@Test public void shouldNotAllowNullPluginIdOrArtifactStoreId() { ArtifactStore store = new ArtifactStore(); store.validate(null); assertThat(store.errors().size(), is(2)); assertThat(store.errors().on(ArtifactStore.PLUGIN_ID), is("Artifact store cannot have a blank plugin id.")); assertThat(store.errors().on(ArtifactStore.ID), is("Artifact store cannot have a blank id.")); }
@Test public void shouldValidateConfigPropertyNameUniqueness() { ConfigurationProperty prop1 = ConfigurationPropertyMother.create("USERNAME"); ConfigurationProperty prop2 = ConfigurationPropertyMother.create("USERNAME"); ArtifactStore store = new ArtifactStore("s3.plugin", "cd.go.s3.plugin", prop1, prop2); store.validate(null); assertThat(store.errors().size(), is(0)); assertThat(prop1.errors().size(), is(1)); assertThat(prop2.errors().size(), is(1)); assertThat(prop1.errors().on(ConfigurationProperty.CONFIGURATION_KEY), is("Duplicate key 'USERNAME' found for Artifact store 's3.plugin'")); assertThat(prop2.errors().on(ConfigurationProperty.CONFIGURATION_KEY), is("Duplicate key 'USERNAME' found for Artifact store 's3.plugin'")); }