MetaDataManagerImpl implements MetaDataManager { @Override public MetaData getMetaData(String appIdentifier) throws MetaDataNotExistsException { MetaData metaData = metaDataRepository.findOne(appIdentifier); if (metaData==null){ throw new MetaDataNotExistsException(); } return metaData; }  @Override MetaData getMetaData(String appIdentifier);  }
@Test public void getMetaDataExist() throws MetaDataNotExistsException{ String idApplication = "9"; Mockito.when(metaDataRepository.findOne(idApplication)).thenReturn(metaData); MetaData response=metaDataManagerImpl.getMetaData(idApplication); Mockito.verify(metaDataRepository).findOne(idApplication); Assert.assertEquals("Response must be equals", metaData,response); }
@Test(expected=MetaDataNotExistsException.class) public void getMetaDataNotExist() throws MetaDataNotExistsException{ String idApplication = "9"; Mockito.when(metaDataRepository.findOne(idApplication)).thenReturn(null); metaDataManagerImpl.getMetaData(idApplication); Mockito.verify(metaDataRepository).findOne(idApplication); }