mirror of
https://github.com/valitydev/wb-list-manager.git
synced 2024-11-06 01:35:17 +00:00
Refactor after review
This commit is contained in:
parent
20953a3203
commit
19fed2ce0b
@ -39,8 +39,7 @@ public class ListRepository implements CrudRepository<Row, String> {
|
||||
.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<Row, String> {
|
||||
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<Row, String> {
|
||||
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<Row, String> {
|
||||
Namespace quotesBucket = new Namespace(bucketName);
|
||||
return new Location(quotesBucket, key);
|
||||
}
|
||||
|
||||
private void handleInterrupt(InterruptedException e, String s) {
|
||||
log.error(s, e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
@ -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<ConfigurableApplicationContext> {
|
||||
@Override
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user