use of com.palantir.atlasdb.keyvalue.impl.ForwardingKeyValueService in project atlasdb by palantir.
the class SchemaMetadataServiceImplTest method canInitializeAsynchronously.
@Test
public void canInitializeAsynchronously() {
ForwardingKeyValueService forwardingKeyValueService = new ForwardingKeyValueService() {
private KeyValueService realKeyValueService = new InMemoryKeyValueService(true);
private boolean fail = true;
@Override
protected KeyValueService delegate() {
if (fail) {
fail = false;
return mock(KeyValueService.class, (Answer) invocation -> {
throw new RuntimeException("I am unhappy");
});
}
return realKeyValueService;
}
};
SchemaMetadataService metadataService = SchemaMetadataServiceImpl.create(forwardingKeyValueService, true);
assertThatThrownBy(() -> metadataService.putSchemaMetadata(SCHEMA_NAME_ONE, SCHEMA_METADATA_ONE)).isInstanceOf(NotInitializedException.class);
Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(metadataService::isInitialized);
metadataService.putSchemaMetadata(SCHEMA_NAME_ONE, SCHEMA_METADATA_ONE);
assertThat(metadataService.loadSchemaMetadata(SCHEMA_NAME_ONE)).contains(SCHEMA_METADATA_ONE);
}
Aggregations