From 469455d23549417fca3e8c7f5d521638e7996612 Mon Sep 17 00:00:00 2001 From: Chi Dov Date: Tue, 11 Sep 2018 00:54:54 -0500 Subject: [PATCH] add unit test for StatisticsServiceClientFallback --- .../StatisticsServiceClientFallbackTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 account-service/src/test/java/com/piggymetrics/account/client/StatisticsServiceClientFallbackTest.java diff --git a/account-service/src/test/java/com/piggymetrics/account/client/StatisticsServiceClientFallbackTest.java b/account-service/src/test/java/com/piggymetrics/account/client/StatisticsServiceClientFallbackTest.java new file mode 100644 index 0000000000..4e21343b01 --- /dev/null +++ b/account-service/src/test/java/com/piggymetrics/account/client/StatisticsServiceClientFallbackTest.java @@ -0,0 +1,43 @@ +package com.piggymetrics.account.client; + +import com.piggymetrics.account.domain.Account; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.hamcrest.Matchers.containsString; + +/** + * @author cdov + */ +@RunWith(SpringRunner.class) +@SpringBootTest(properties = { + "feign.hystrix.enabled=true" +}) +public class StatisticsServiceClientFallbackTest { + @Autowired + private StatisticsServiceClient statisticsServiceClient; + + @Rule + public final OutputCapture outputCapture = new OutputCapture(); + + @Before + public void setup() { + outputCapture.reset(); + } + + @Test + public void testUpdateStatisticsWithFailFallback(){ + statisticsServiceClient.updateStatistics("test", new Account()); + + outputCapture.expect(containsString("Error during update statistics for account: test")); + + } + +} +