When get key/value in a transaction then the value is returned

This commit is contained in:
Paul Campbell 2018-06-15 18:58:53 +01:00
parent c506802224
commit cdd35e8008
2 changed files with 17 additions and 3 deletions

View file

@ -44,8 +44,8 @@ class GitDBTransactionImpl implements GitDBTransaction {
} }
@Override @Override
public Optional<String> get(String key) { public Optional<String> get(String key) throws IOException {
return Optional.empty(); return branch.get(key);
} }
@Override @Override

View file

@ -246,7 +246,7 @@ class GitDBTest implements WithAssertions {
// When getting a key that does exist then the value is returned inside an Optional // When getting a key that does exist then the value is returned inside an Optional
@Test @Test
void getValue_whenExists_thenReturnValueInOptional() throws IOException, ClassNotFoundException { void getKey_whenExists_thenReturnValueInOptional() throws IOException, ClassNotFoundException {
//given //given
final String key = stringSupplier.get(); final String key = stringSupplier.get();
final String value = stringSupplier.get(); final String value = stringSupplier.get();
@ -434,6 +434,20 @@ class GitDBTest implements WithAssertions {
assertThat(formatVersion).contains(GitDB.VERSION); 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 // Given a GitDbTransaction handle with a added, updated and removed keys
// When closing the transaction an GitDbBranch is returned // When closing the transaction an GitDbBranch is returned
// When closing the transaction the added key/value is found // When closing the transaction the added key/value is found