ValidatorExistFeature { public void checkFeatureExist(String idApplication, String idFeature) throws FeatureNotExistException{ Feature feature = featureRepository.findByApplicationIdentifierAndId(idApplication, idFeature); if (feature==null){ throw new FeatureNotExistException(); } }  void checkFeatureExist(String idApplication, String idFeature);  }
@Test public void checkFeatureExist() throws FeatureNotExistException{ String idApplication = "9"; String idFeature = "1"; Mockito.when(featureRepository.findByApplicationIdentifierAndId(idApplication, idFeature)).thenReturn(feature); validatorExistFeature.checkFeatureExist(idApplication, idFeature); Mockito.verify(featureRepository).findByApplicationIdentifierAndId(idApplication, idFeature); }
@Test(expected=FeatureNotExistException.class) public void checkFeatureNotExist() throws FeatureNotExistException{ String idApplication = "9"; String idFeature = "1"; Mockito.when(featureRepository.findByApplicationIdentifierAndId(idApplication, idFeature)).thenReturn(null); validatorExistFeature.checkFeatureExist(idApplication, idFeature); Mockito.verify(featureRepository).findByApplicationIdentifierAndId(idApplication, idFeature); }