@Test public void findNonExisting() throws Exception { Optional<TapeArchiveReferentialEntity> tarReferentialEntity = archiveReferentialRepository.find("tarId1"); assertThat(tarReferentialEntity.isPresent()).isFalse(); }
public Optional<TapeArchiveReferentialEntity> find(String archiveId) throws ArchiveReferentialException { Document document; try { document = collection.find( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId)) .first(); } catch (MongoException ex) { throw new ArchiveReferentialException("Could not find storage location by id " + archiveId, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeArchiveReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } }
ArchiveReferentialRepository { public Optional<TapeArchiveReferentialEntity> find(String archiveId) throws ArchiveReferentialException { Document document; try { document = collection.find( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId)) .first(); } catch (MongoException ex) { throw new ArchiveReferentialException("Could not find storage location by id " + archiveId, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeArchiveReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } }
ArchiveReferentialRepository { public Optional<TapeArchiveReferentialEntity> find(String archiveId) throws ArchiveReferentialException { Document document; try { document = collection.find( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId)) .first(); } catch (MongoException ex) { throw new ArchiveReferentialException("Could not find storage location by id " + archiveId, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeArchiveReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } ArchiveReferentialRepository(MongoCollection<Document> collection); }
ArchiveReferentialRepository { public Optional<TapeArchiveReferentialEntity> find(String archiveId) throws ArchiveReferentialException { Document document; try { document = collection.find( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId)) .first(); } catch (MongoException ex) { throw new ArchiveReferentialException("Could not find storage location by id " + archiveId, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeArchiveReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } ArchiveReferentialRepository(MongoCollection<Document> collection); void insert(TapeArchiveReferentialEntity tapeArchiveReferentialEntity); Optional<TapeArchiveReferentialEntity> find(String archiveId); void updateLocationToReadyOnDisk(String archiveId, long size, String digest); void updateLocationToOnTape(String archiveId,
        TapeLibraryOnTapeArchiveStorageLocation onTapeTarStorageLocation); }
ArchiveReferentialRepository { public Optional<TapeArchiveReferentialEntity> find(String archiveId) throws ArchiveReferentialException { Document document; try { document = collection.find( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId)) .first(); } catch (MongoException ex) { throw new ArchiveReferentialException("Could not find storage location by id " + archiveId, ex); } if (document == null) { return Optional.empty(); } try { return Optional.of(fromBson(document, TapeArchiveReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e); } } ArchiveReferentialRepository(MongoCollection<Document> collection); void insert(TapeArchiveReferentialEntity tapeArchiveReferentialEntity); Optional<TapeArchiveReferentialEntity> find(String archiveId); void updateLocationToReadyOnDisk(String archiveId, long size, String digest); void updateLocationToOnTape(String archiveId,
        TapeLibraryOnTapeArchiveStorageLocation onTapeTarStorageLocation);  }