When get key/value in a transaction then the value is returned
This commit is contained in:
parent
c506802224
commit
cdd35e8008
2 changed files with 17 additions and 3 deletions
|
@ -44,8 +44,8 @@ class GitDBTransactionImpl implements GitDBTransaction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> get(String key) {
|
||||
return Optional.empty();
|
||||
public Optional<String> get(String key) throws IOException {
|
||||
return branch.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -246,7 +246,7 @@ class GitDBTest implements WithAssertions {
|
|||
|
||||
// When getting a key that does exist then the value is returned inside an Optional
|
||||
@Test
|
||||
void getValue_whenExists_thenReturnValueInOptional() throws IOException, ClassNotFoundException {
|
||||
void getKey_whenExists_thenReturnValueInOptional() throws IOException, ClassNotFoundException {
|
||||
//given
|
||||
final String key = stringSupplier.get();
|
||||
final String value = stringSupplier.get();
|
||||
|
@ -434,6 +434,20 @@ class GitDBTest implements WithAssertions {
|
|||
assertThat(formatVersion).contains(GitDB.VERSION);
|
||||
}
|
||||
|
||||
// When get key/value in a transaction then the value is returned
|
||||
@Test
|
||||
void getKey_whenTransaction_thenReturnValueInOptional() throws IOException {
|
||||
//given
|
||||
final String key = stringSupplier.get();
|
||||
final String value = stringSupplier.get();
|
||||
final GitDBBranch gitDBBranch = gitDBBranchWithKeyValue(key, value);
|
||||
final GitDBTransaction transaction = gitDBBranch.transaction();
|
||||
//when
|
||||
final Optional<String> result = transaction.get(key);
|
||||
//then
|
||||
assertThat(result).contains(value);
|
||||
}
|
||||
|
||||
// Given a GitDbTransaction handle with a added, updated and removed keys
|
||||
// When closing the transaction an GitDbBranch is returned
|
||||
// When closing the transaction the added key/value is found
|
||||
|
|
Loading…
Reference in a new issue