Helper { public void validate(List<VersionModule> modules) { if (modules == null || modules.isEmpty()) { throw new IllegalArgumentException("No modules found."); } for (VersionModule module : modules) { if (!Utils.hasAnnotatedMethods(module.getClass(), VersionCode.class)) { throw new IllegalArgumentException("No annotated method found."); } } } Helper(Application application); void validate(List<VersionModule> modules); void execute(int baseVersion, List<VersionModule> modules); static final String TAG; }
@Test public void validation() throws Exception { List<VersionModule> modules = new ArrayList<VersionModule>(); modules.add(new MockModule()); mHelper.validate(modules); }
@Test(expected = IllegalArgumentException.class) public void validationFailure_null() throws Exception { mHelper.validate(null); }
@Test(expected = IllegalArgumentException.class) public void validationFailure_empty() throws Exception { mHelper.validate(new ArrayList<VersionModule>()); }
@Test(expected = IllegalArgumentException.class) public void validationFailure_noAnnotation() throws Exception { List<VersionModule> modules = new ArrayList<VersionModule>(); modules.add(new NoAnnotationModule()); mHelper.validate(modules); }