use of com.meniga.sdk.models.transactions.MenigaTransactionPage in project mobile-sdk-android by meniga.
the class MenigaTransactionOperationsMock method splitTransaction.
@Override
public Result<List<MenigaTransaction>> splitTransaction(long parentId, MenigaDecimal amount, String text, long categoryId, boolean isFlagged) {
TaskCompletionSource<List<MenigaTransaction>> task = new TaskCompletionSource<>();
task.setResult(new MenigaTransactionPage());
return new MTask<>(task.getTask(), task);
}
use of com.meniga.sdk.models.transactions.MenigaTransactionPage in project mobile-sdk-android by meniga.
the class MenigaTransactionsTest method test.
@Test
public void test() throws Exception {
// Create a MockWebServer. These are lean enough that you can create a new
// instance for every unit test.
MockWebServer server = new MockWebServer();
// Schedule some responses.
server.enqueue(new MockResponse().setBody(FileImporter.getJsonFileFromRaw("transactionsPage.json")));
// Start the server.
server.start();
// Ask the server for its URL. You'll need this to make HTTP requests.
HttpUrl baseUrl = server.url("/v1");
MenigaSettings settings = new MenigaSettings.Builder().endpoint(baseUrl).build();
MenigaSDK.init(settings);
Task<MenigaTransactionPage> transactionsTask = MenigaTransaction.fetch(new TransactionsFilter.Builder().build()).getTask();
transactionsTask.waitForCompletion();
MenigaTransactionPage transactionPage = transactionsTask.getResult();
Assert.assertNotNull(transactionPage);
// Shut down the server. Instances cannot be reused.
server.shutdown();
}
use of com.meniga.sdk.models.transactions.MenigaTransactionPage in project mobile-sdk-android by meniga.
the class MenigaTransactionOperationsMock method gson.
private MenigaTransactionPage gson() {
Gson gson = GsonProvider.getGsonBuilder();
MenigaTransactionPage transactionPage = null;
try {
InputStream inputStream = FileImporter.getInputStreamFromRaw("transactions.json");
MenigaTransaction[] arr = gson.fromJson(MenigaConverter.getAsArray(inputStream), MenigaTransaction[].class);
transactionPage = new MenigaTransactionPage();
transactionPage.addAll(Arrays.asList(arr));
} catch (IOException e) {
e.printStackTrace();
}
return transactionPage;
}
Aggregations