ImportRepositoryCustomImpl implements ImportRepositoryCustom { public void deleteLockImportProcess(String appIdentifier) throws QueryException{ BasicQuery basicquery; try{ basicquery = new BasicQuery("{ '_id':'" + appIdentifier + "'}"); }catch(Exception e) { throw new QueryException(); } if(mongoTemplate.collectionExists(collectionLock)){ mongoTemplate.remove(basicquery, collectionLock); } }  @Override String saveGeoJson(String appIdentifier, Collection<Feature> featureCollection); void lockImportProcess(String appIdentifier); boolean isImportProcessLocked(String appIdentifier); void deleteLockImportProcess(String appIdentifier);  }
@Test public void deleteLockImportProcess() throws Exception{ String idApplication = "1"; String strQuery = "{ '_id':'" + idApplication + "'}"; PowerMockito.whenNew(BasicQuery.class).withArguments(strQuery).thenReturn(basicQuery); Mockito.when(mongoTemplate.collectionExists(collectionLock)).thenReturn(true); importRepositoryCustom.deleteLockImportProcess(idApplication); verify(mongoTemplate).collectionExists(collectionLock); verify(mongoTemplate).remove(basicQuery,collectionLock); }