Skip to content

Commit 0f784e4

Browse files
Update QaSchema IT to use TestKit [ECR-3054] (#899)
Use testkit instead of memoryDb to access the database state.
1 parent 487ae07 commit 0f784e4

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

exonum-java-binding/qa-service/src/test/java/com/exonum/binding/qaservice/QaSchemaIntegrationTest.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@
1919
import static org.assertj.core.api.Assertions.assertThat;
2020

2121
import com.exonum.binding.common.hash.HashCode;
22-
import com.exonum.binding.proxy.Cleaner;
23-
import com.exonum.binding.proxy.CloseFailuresException;
24-
import com.exonum.binding.storage.database.Database;
25-
import com.exonum.binding.storage.database.MemoryDb;
26-
import com.exonum.binding.storage.database.Snapshot;
2722
import com.exonum.binding.test.RequiresNativeLibrary;
23+
import com.exonum.binding.testkit.TestKit;
2824
import com.exonum.binding.util.LibraryLoader;
2925
import java.util.List;
3026
import org.junit.jupiter.api.BeforeAll;
@@ -39,20 +35,19 @@ static void loadLibrary() {
3935
}
4036

4137
@Test
42-
void getStateHashesEmptyDb() throws CloseFailuresException {
43-
try (Database db = MemoryDb.newInstance();
44-
Cleaner cleaner = new Cleaner()) {
45-
Snapshot snapshot = db.createSnapshot(cleaner);
46-
QaSchema schema = new QaSchema(snapshot);
38+
void getStateHashesEmptyDb() {
39+
try (TestKit testKit = TestKit.forService(QaServiceModule.class)) {
40+
testKit.withSnapshot((view) -> {
41+
QaSchema schema = new QaSchema(view);
4742

48-
List<HashCode> stateHashes = schema.getStateHashes();
43+
List<HashCode> stateHashes = schema.getStateHashes();
4944

50-
assertThat(stateHashes)
51-
.hasSize(1);
45+
assertThat(stateHashes).hasSize(1);
5246

53-
HashCode countersRootHash = schema.counters().getRootHash();
54-
assertThat(stateHashes.get(0))
55-
.isEqualTo(countersRootHash);
47+
HashCode countersRootHash = schema.counters().getRootHash();
48+
assertThat(stateHashes.get(0)).isEqualTo(countersRootHash);
49+
return null;
50+
});
5651
}
5752
}
5853
}

0 commit comments

Comments
 (0)