diff --git a/src/main/java/com/rbkmoney/wb/list/manager/repository/ListRepository.java b/src/main/java/com/rbkmoney/wb/list/manager/repository/ListRepository.java index 872ab8b..aacf2ff 100644 --- a/src/main/java/com/rbkmoney/wb/list/manager/repository/ListRepository.java +++ b/src/main/java/com/rbkmoney/wb/list/manager/repository/ListRepository.java @@ -39,8 +39,7 @@ public class ListRepository implements CrudRepository { .build(); client.execute(storeOp); } catch (InterruptedException e) { - log.error("InterruptedException in ListRepository when create e: ", e); - Thread.currentThread().interrupt(); + handleInterrupt(e, "InterruptedException in ListRepository when create e: "); throw new RiakExecutionException(e); } catch (Exception e) { log.error("Exception in ListRepository when create e: ", e); @@ -55,8 +54,7 @@ public class ListRepository implements CrudRepository { DeleteValue delete = new DeleteValue.Builder(quoteObjectLocation).build(); client.execute(delete); } catch (InterruptedException e) { - log.error("InterruptedException in ListRepository when remove e: ", e); - Thread.currentThread().interrupt(); + handleInterrupt(e, "InterruptedException in ListRepository when remove e: "); throw new RiakExecutionException(e); } catch (ExecutionException e) { log.error("Exception in ListRepository when remove e: ", e); @@ -76,8 +74,7 @@ public class ListRepository implements CrudRepository { return obj != null && obj.getValue() != null ? Optional.of(new Row(bucket, key, obj.getValue().toString())) : Optional.empty(); } catch (InterruptedException e) { - log.error("InterruptedException in ListRepository when get e: ", e); - Thread.currentThread().interrupt(); + handleInterrupt(e, "InterruptedException in ListRepository when get e: "); throw new RiakExecutionException(e); } catch (Exception e) { log.error("Exception in ListRepository when get e: ", e); @@ -89,4 +86,9 @@ public class ListRepository implements CrudRepository { Namespace quotesBucket = new Namespace(bucketName); return new Location(quotesBucket, key); } + + private void handleInterrupt(InterruptedException e, String s) { + log.error(s, e); + Thread.currentThread().interrupt(); + } } diff --git a/src/test/java/com/rbkmoney/wb/list/manager/KafkaAbstractTest.java b/src/test/java/com/rbkmoney/wb/list/manager/KafkaAbstractTest.java index 5f1ce2b..953cf5d 100644 --- a/src/test/java/com/rbkmoney/wb/list/manager/KafkaAbstractTest.java +++ b/src/test/java/com/rbkmoney/wb/list/manager/KafkaAbstractTest.java @@ -19,8 +19,10 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen @ContextConfiguration(initializers = KafkaAbstractTest.Initializer.class) public abstract class KafkaAbstractTest { + public static final String KAFKA_DOCKER_VERSION = "5.0.1"; + @ClassRule - public static KafkaContainer kafka = new KafkaContainer("5.0.1").withEmbeddedZookeeper(); + public static KafkaContainer kafka = new KafkaContainer(KAFKA_DOCKER_VERSION).withEmbeddedZookeeper(); public static class Initializer implements ApplicationContextInitializer { @Override diff --git a/src/test/java/com/rbkmoney/wb/list/manager/WbListManagerApplicationTest.java b/src/test/java/com/rbkmoney/wb/list/manager/WbListManagerApplicationTest.java index 16acd71..132dbfa 100644 --- a/src/test/java/com/rbkmoney/wb/list/manager/WbListManagerApplicationTest.java +++ b/src/test/java/com/rbkmoney/wb/list/manager/WbListManagerApplicationTest.java @@ -59,10 +59,12 @@ public class WbListManagerApplicationTest extends KafkaAbstractTest { @LocalServerPort int serverPort; + private static String SERVICE_URL = "http://localhost:%s/v1/wb_list"; @Autowired private ListRepository listRepository; + @Autowired private RiakClient client; @@ -90,7 +92,7 @@ public class WbListManagerApplicationTest extends KafkaAbstractTest { } @Test - public void contextLoads() throws ExecutionException, InterruptedException { + public void riakTest() throws ExecutionException, InterruptedException { Row row = new Row(); row.setKey(KEY); row.setBucketName(BUCKET_NAME);