@Test(expected = DatabaseException.class) public void testRemoveNotExists() throws DatabaseException { String id = GUIDFactory.newGUID().toString(); Integer tenant = 0; repository.remove(id, tenant); }
@Override public void remove(String id, Integer tenant) throws DatabaseException { ParametersChecker.checkParameter(ALL_PARAMS_REQUIRED, id); DeleteResult delete = collection.deleteOne(new BasicDBObject(ID, id)); long count = delete.getDeletedCount(); if (count == 0) { LOGGER.error(String.format("Document %s is not deleted", id)); throw new DatabaseException(String.format("Document %s is not deleted", id)); } }
VitamMongoRepository implements VitamRepository { @Override public void remove(String id, Integer tenant) throws DatabaseException { ParametersChecker.checkParameter(ALL_PARAMS_REQUIRED, id); DeleteResult delete = collection.deleteOne(new BasicDBObject(ID, id)); long count = delete.getDeletedCount(); if (count == 0) { LOGGER.error(String.format("Document %s is not deleted", id)); throw new DatabaseException(String.format("Document %s is not deleted", id)); } } }
VitamMongoRepository implements VitamRepository { @Override public void remove(String id, Integer tenant) throws DatabaseException { ParametersChecker.checkParameter(ALL_PARAMS_REQUIRED, id); DeleteResult delete = collection.deleteOne(new BasicDBObject(ID, id)); long count = delete.getDeletedCount(); if (count == 0) { LOGGER.error(String.format("Document %s is not deleted", id)); throw new DatabaseException(String.format("Document %s is not deleted", id)); } } VitamMongoRepository(MongoCollection<Document> collection); }
VitamMongoRepository implements VitamRepository { @Override public void remove(String id, Integer tenant) throws DatabaseException { ParametersChecker.checkParameter(ALL_PARAMS_REQUIRED, id); DeleteResult delete = collection.deleteOne(new BasicDBObject(ID, id)); long count = delete.getDeletedCount(); if (count == 0) { LOGGER.error(String.format("Document %s is not deleted", id)); throw new DatabaseException(String.format("Document %s is not deleted", id)); } } VitamMongoRepository(MongoCollection<Document> collection); @Override void save(Document document); @Override VitamRepositoryStatus saveOrUpdate(Document document); @Override void save(List<Document> documents); @Override void saveOrUpdate(List<Document> documents); @Override void update(List<WriteModel<Document>> queries); @Override void remove(String id, Integer tenant); @Override long remove(Bson query); @Override void removeByNameAndTenant(String name, Integer tenant); @Override long purge(Integer tenant); @Override long purge(); @Override Optional<Document> getByID(String id, Integer tenant); @Override Optional<Document> findByIdentifierAndTenant(String identifier, Integer tenant); @Override Optional<Document> findByIdentifier(String identifier); @Override FindIterable<Document> findByFieldsDocuments(Map<String, String> fields, int mongoBatchSize,
        Integer tenant); @Override FindIterable<Document> findDocuments(Collection<String> ids, Bson projection); @Override FindIterable<Document> findDocuments(int mongoBatchSize, Integer tenant); @Override FindIterable<Document> findDocuments(int mongoBatchSize); @Override FindIterable<Document> findDocuments(Bson query, int mongoBatchSize); @Override void delete(List<String> ids, int tenant); }
VitamMongoRepository implements VitamRepository { @Override public void remove(String id, Integer tenant) throws DatabaseException { ParametersChecker.checkParameter(ALL_PARAMS_REQUIRED, id); DeleteResult delete = collection.deleteOne(new BasicDBObject(ID, id)); long count = delete.getDeletedCount(); if (count == 0) { LOGGER.error(String.format("Document %s is not deleted", id)); throw new DatabaseException(String.format("Document %s is not deleted", id)); } } VitamMongoRepository(MongoCollection<Document> collection); @Override void save(Document document); @Override VitamRepositoryStatus saveOrUpdate(Document document); @Override void save(List<Document> documents); @Override void saveOrUpdate(List<Document> documents); @Override void update(List<WriteModel<Document>> queries); @Override void remove(String id, Integer tenant); @Override long remove(Bson query); @Override void removeByNameAndTenant(String name, Integer tenant); @Override long purge(Integer tenant); @Override long purge(); @Override Optional<Document> getByID(String id, Integer tenant); @Override Optional<Document> findByIdentifierAndTenant(String identifier, Integer tenant); @Override Optional<Document> findByIdentifier(String identifier); @Override FindIterable<Document> findByFieldsDocuments(Map<String, String> fields, int mongoBatchSize,
        Integer tenant); @Override FindIterable<Document> findDocuments(Collection<String> ids, Bson projection); @Override FindIterable<Document> findDocuments(int mongoBatchSize, Integer tenant); @Override FindIterable<Document> findDocuments(int mongoBatchSize); @Override FindIterable<Document> findDocuments(Bson query, int mongoBatchSize); @Override void delete(List<String> ids, int tenant); static final String NAME; }