Commit be8ab618 authored by Aurelien Pupier's avatar Aurelien Pupier
Browse files

BS-14159: warn user when a validator is invalid instead of having a NPE

- use a FileNotFoundException instead of RuntimeException to be more
precise
parent 479056d3
......@@ -95,6 +95,8 @@ public class ValidatorBarResourceProviderTest {
} catch (final RuntimeException e) {
Assertions.assertThat(e.getMessage()).isEqualTo("Invalid validator definition " + validatorId + "!");
return;
} catch (final FileNotFoundException e) {
e.printStackTrace();
}
fail("A clean RuntimeException should have been thrown.");
}
......@@ -114,6 +116,8 @@ public class ValidatorBarResourceProviderTest {
try {
provider.addResourcesForConfiguration(builder, (AbstractProcess) null, configuration, Collections.<EObject> emptySet());
} catch (final RuntimeException e) {
e.printStackTrace();
} catch (final FileNotFoundException e) {
Assertions.assertThat(e.getMessage()).isEqualTo(
"Validator class " + className + " not found for validator definition " + validatorId + "!");
return;
......
......@@ -48,7 +48,7 @@ public class ValidatorBarResourceProvider implements BARResourcesProvider {
@Override
public void addResourcesForConfiguration(final BusinessArchiveBuilder builder, final AbstractProcess process, final Configuration configuration,
final Set<EObject> exludedObject) {
final Set<EObject> exludedObject) throws FileNotFoundException {
if (configuration == null) {
return;
}
......@@ -59,7 +59,7 @@ public class ValidatorBarResourceProvider implements BARResourcesProvider {
}
}
protected List<BarResource> findAndCreateBarResourceForValidator(final Configuration configuration) {
protected List<BarResource> findAndCreateBarResourceForValidator(final Configuration configuration) throws FileNotFoundException {
final List<BarResource> resources = new ArrayList<BarResource>();
final ValidatorDescriptorRepositoryStore validatorDescStore = getRepositoryAccessor().getRepositoryStore(ValidatorDescriptorRepositoryStore.class);
final ValidatorSourceRepositorySotre validatorSourceStore = getRepositoryAccessor().getRepositoryStore(ValidatorSourceRepositorySotre.class);
......@@ -87,10 +87,10 @@ public class ValidatorBarResourceProvider implements BARResourcesProvider {
}
protected SourceFileStore findSourceFileStoreForValidator(final ValidatorSourceRepositorySotre validatorSourceStore, final String validatorId,
final ValidatorDescriptor descriptor) {
final ValidatorDescriptor descriptor) throws FileNotFoundException {
final AbstractFileStore child = validatorSourceStore.getChild(descriptor.getClassName());
if (child == null) {
throw new RuntimeException("Validator class " + descriptor.getClassName() + " not found for validator definition " + validatorId + "!");
throw new FileNotFoundException("Validator class " + descriptor.getClassName() + " not found for validator definition " + validatorId + "!");
}
if (!(child instanceof SourceFileStore)) {
throw new RuntimeException("Invalid validator definition " + validatorId + "!");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment