-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from DataINCITE/flynnc3-temp
add edge case support for response and heartbeat interaction
- Loading branch information
Showing
4 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...ine/src/test/java/test/stream/external/connected/connections/TestAmberDataConnection.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| package test.stream.external.connected.connections; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
| import java.util.Scanner; | ||
|
|
||
| import org.apache.log4j.Level; | ||
| import org.apache.log4j.LogManager; | ||
| import org.core.core.Core; | ||
| import org.framework.router.Response; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
|
|
||
| public class TestAmberDataConnection { | ||
|
|
||
| static { | ||
| // disable loggers | ||
| LogManager.getRootLogger().setLevel(Level.OFF); | ||
| } | ||
|
|
||
| private static String apikey; | ||
|
|
||
| @BeforeClass | ||
| public static void init() throws FileNotFoundException { | ||
| Scanner s = new Scanner(new File("src/test/resources/" | ||
| + "test/stream/external/connected/connections/" | ||
| + "test_amberdata_config.txt")); | ||
| apikey = s.nextLine(); | ||
| s.close(); | ||
| } | ||
|
|
||
| //@Test | ||
| public void TestAuthorization() { | ||
| Core core = new Core(); | ||
|
|
||
| // successful authorization | ||
| assertEquals(200, core.send("SRC", "INIT", "amber_data," + apikey).code()); | ||
|
|
||
| // failed authorization | ||
| assertEquals(422, core.send("SRC", "INIT", "amber_data, does_not_exist").code()); | ||
| } | ||
|
|
||
| //@Test | ||
| public void TestRequest() { | ||
| Core core = new Core(); | ||
|
|
||
| Response initResponse = core.send("SRC", "INIT", "amber_data," + apikey); | ||
|
|
||
| assertEquals(200, initResponse.code()); | ||
|
|
||
| String key = initResponse.data().split(",")[1].trim(); | ||
|
|
||
| Response valid = core.send("SRC", "RQST", String.format("%s, %s", key, "lending-latest")); | ||
| assertEquals(200, valid.code()); | ||
|
|
||
| // invalid request | ||
| Response invalid = core.send("SRC", "RQST", String.format("%s, %s", key, "does_not_exist")); | ||
| assertEquals(428, invalid.code()); | ||
| } | ||
|
|
||
| @Test | ||
| public void TestAaveProtocolDated() throws IOException { | ||
| // HashMap<String, String> params = new HashMap<String, String>(); | ||
| // params.put("start_date", "2022-09-01"); | ||
| // params.put("end_date", "2022-09-05"); | ||
| // System.out.println(AmberDataRequestHandler.requestAaveProtocolDated("2022-09-01", "2022-09-05", "UAK7ed69235426c360be22bfc2bde1809b6")[1]); | ||
| //System.out.println(AmberDataRequestHandler.requestLendingLatest(apikey, "")[1]); | ||
| //System.out.println(AmberDataRequestHandler.request("aave-protocol-dated", apikey, params)[1]); | ||
|
|
||
| // OkHttpClient client = new OkHttpClient(); | ||
| // | ||
| // Request request = new Request.Builder() | ||
| // .url("https://web3api.io/api/v2/defi/lending/aavev2/protocol?startDate=2022-09-01T01:00:00&endDate=2022-09-05T01:00:00") | ||
| // .get() | ||
| // .addHeader("accept", "application/json") | ||
| // .addHeader("x-api-key", "UAK7ed69235426c360be22bfc2bde1809b6") | ||
| // .build(); | ||
| // | ||
| // okhttp3.Response response = client.newCall(request).execute(); | ||
| // System.out.println(response.body().string().substring(0, 1000)); | ||
| } | ||
| } |
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
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
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