-
-
Save jasongorman/7b2a9f41ab750c578573a4e1e9270ff1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.guitarshack; | |
import com.guitarshack.net.Network; | |
import com.guitarshack.net.RESTClient; | |
import com.guitarshack.net.RequestBuilder; | |
import com.guitarshack.sales.SalesData; | |
import org.junit.Test; | |
import java.util.Calendar; | |
import static org.junit.Assert.assertTrue; | |
/* | |
This Abstract Test allows us to create two versions of the set-up, one with | |
stubbed JSON and one that actually connects to the web service, effectively pinpointing | |
whether an error has occurred because of a change to our code or a change to the external dependency | |
*/ | |
public abstract class SalesDataTestBase { | |
@Test | |
public void fetchesSalesData(){ | |
SalesData salesData = new SalesData(new RESTClient(getNetwork(), new RequestBuilder()), () -> { | |
Calendar calendar = Calendar.getInstance(); | |
calendar.set(2019, Calendar.JANUARY, 31); | |
return calendar.getTime(); | |
}); | |
int total = salesData.getTotal(811); | |
assertTrue(total > 0); | |
} | |
protected abstract Network getNetwork(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment