@Test public void findNonExisting() throws Exception { Optional<TapeObjectReferentialEntity> tapeObjectReferentialEntity = objectReferentialRepository.find("container", "objectName1"); assertThat(tapeObjectReferentialEntity.isPresent()).isFalse(); }
public Optional<TapeObjectReferentialEntity> find(String containerName, String objectName) throws ObjectReferentialException { Document document; try { document = collection.find( Filters.eq(TapeObjectReferentialEntity.ID, toBson(new TapeLibraryObjectReferentialId(containerName, objectName)))) .first(); } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by id " + containerName + "/" + objectName, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } }
ObjectReferentialRepository { public Optional<TapeObjectReferentialEntity> find(String containerName, String objectName) throws ObjectReferentialException { Document document; try { document = collection.find( Filters.eq(TapeObjectReferentialEntity.ID, toBson(new TapeLibraryObjectReferentialId(containerName, objectName)))) .first(); } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by id " + containerName + "/" + objectName, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } }
ObjectReferentialRepository { public Optional<TapeObjectReferentialEntity> find(String containerName, String objectName) throws ObjectReferentialException { Document document; try { document = collection.find( Filters.eq(TapeObjectReferentialEntity.ID, toBson(new TapeLibraryObjectReferentialId(containerName, objectName)))) .first(); } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by id " + containerName + "/" + objectName, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } ObjectReferentialRepository(MongoCollection<Document> collection); }
ObjectReferentialRepository { public Optional<TapeObjectReferentialEntity> find(String containerName, String objectName) throws ObjectReferentialException { Document document; try { document = collection.find( Filters.eq(TapeObjectReferentialEntity.ID, toBson(new TapeLibraryObjectReferentialId(containerName, objectName)))) .first(); } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by id " + containerName + "/" + objectName, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } ObjectReferentialRepository(MongoCollection<Document> collection); void insertOrUpdate(TapeObjectReferentialEntity tapeObjectReferentialEntity); Optional<TapeObjectReferentialEntity> find(String containerName, String objectName); List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames); void updateStorageLocation(String containerName, String objectName, String storageId,
        TapeLibraryTarObjectStorageLocation tapeLibraryTarStorageLocation); boolean delete(TapeLibraryObjectReferentialId tapeLibraryObjectReferentialId); }
ObjectReferentialRepository { public Optional<TapeObjectReferentialEntity> find(String containerName, String objectName) throws ObjectReferentialException { Document document; try { document = collection.find( Filters.eq(TapeObjectReferentialEntity.ID, toBson(new TapeLibraryObjectReferentialId(containerName, objectName)))) .first(); } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by id " + containerName + "/" + objectName, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } ObjectReferentialRepository(MongoCollection<Document> collection); void insertOrUpdate(TapeObjectReferentialEntity tapeObjectReferentialEntity); Optional<TapeObjectReferentialEntity> find(String containerName, String objectName); List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames); void updateStorageLocation(String containerName, String objectName, String storageId,
        TapeLibraryTarObjectStorageLocation tapeLibraryTarStorageLocation); boolean delete(TapeLibraryObjectReferentialId tapeLibraryObjectReferentialId);  }