CassandraMessageFastViewProjection implements MessageFastViewProjection { @Override public Mono<MessageFastViewPrecomputedProperties> retrieve(MessageId messageId) { checkMessage(messageId); return cassandraAsyncExecutor.executeSingleRow(retrieveStatement.bind() .setUUID(MESSAGE_ID, ((CassandraMessageId) messageId).get()) .setConsistencyLevel(ConsistencyLevel.ONE)) .map(this::fromRow) .doOnNext(preview -> metricRetrieveHitCount.increment()) .switchIfEmpty(Mono.fromRunnable(metricRetrieveMissCount::increment)) .onErrorResume(e -> { LOGGER.error("Error while retrieving MessageFastView projection item for {}", messageId, e); return Mono.empty(); }); } @Inject  CassandraMessageFastViewProjection(MetricFactory metricFactory, Session session); @Override Mono<Void> store(MessageId messageId, MessageFastViewPrecomputedProperties precomputedProperties); @Override Mono<MessageFastViewPrecomputedProperties> retrieve(MessageId messageId); @Override Mono<Void> delete(MessageId messageId); @Override Mono<Void> clear(); static final Logger LOGGER; }
@Test void retrieveShouldThrowWhenMessageIdIsNotCassandraType() { assertThatThrownBy(() -> testee.retrieve(TestMessageId.of(1))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("MessageId type is required to be CassandraMessageId"); }
@Test void deleteShouldThrowWhenMessageIdIsNotCassandraType() { assertThatThrownBy(() -> testee.retrieve(TestMessageId.of(1))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("MessageId type is required to be CassandraMessageId"); }