/** * Rigourous Test :-) */ public void testIsValidArgument() { Institution institution = new Institution("EBI"); BioSource bioSource = new BioSource(institution, "human", "9606"); CvInteractorType cvInteractorType = new CvInteractorType(institution,"protein"); Protein protein = new ProteinImpl(institution, bioSource, "lsm7", cvInteractorType); // This should return true. assertTrue(MethodArgumentValidator.isValidArgument(protein,Protein.class) ); // This should return true as Protein is a sub class of Interactor assertTrue(MethodArgumentValidator.isValidArgument(protein,Interactor.class) ); //This should send an IllegalArgumentException try{ MethodArgumentValidator.isValidArgument(protein,BioSource.class); fail("This should have sent and IllegalArgumentException as protein is not a BioSource"); }catch(IllegalArgumentException e){ assertTrue(true); } //This should send an NullPointerException try{ assertTrue(MethodArgumentValidator.isValidArgument(null,Interactor.class) ); fail("This should have sent and NullPointerException as protein is null"); }catch( NullPointerException e){ assertTrue(true); } }