Search in sources :

Example 1 with JacksonResponseReader

use of si.mazi.rescu.serialization.jackson.JacksonResponseReader in project XChange by knowm.

the class PoloniexOrderTest method sellRejectTest.

@Test(expected = PoloniexException.class)
public void sellRejectTest() throws Exception {
    InvocationResult invocationResult = new InvocationResult("{\"error\":\"Not enough LTC.\"}", 200);
    Method apiMethod = PoloniexAuthenticated.class.getDeclaredMethod("sell", String.class, ParamsDigest.class, SynchronizedValueFactory.class, String.class, String.class, String.class, Integer.class, Integer.class, Integer.class);
    RestMethodMetadata data = RestMethodMetadata.create(apiMethod, "", "");
    try {
        new JacksonResponseReader(new DefaultJacksonObjectMapperFactory().createObjectMapper(), false).read(invocationResult, data);
    } catch (PoloniexException e) {
        Assert.assertTrue(e.getMessage().startsWith("Not enough LTC."));
        throw e;
    }
}
Also used : DefaultJacksonObjectMapperFactory(si.mazi.rescu.serialization.jackson.DefaultJacksonObjectMapperFactory) Method(java.lang.reflect.Method) InvocationResult(si.mazi.rescu.InvocationResult) JacksonResponseReader(si.mazi.rescu.serialization.jackson.JacksonResponseReader) PoloniexException(org.knowm.xchange.poloniex.dto.PoloniexException) RestMethodMetadata(si.mazi.rescu.RestMethodMetadata) Test(org.junit.Test)

Example 2 with JacksonResponseReader

use of si.mazi.rescu.serialization.jackson.JacksonResponseReader in project XChange by knowm.

the class PoloniexOrderTest method moveOrderRejectTest.

@Test(expected = PoloniexException.class)
public void moveOrderRejectTest() throws Exception {
    InvocationResult invocationResult = new InvocationResult("{\"success\":0,\"error\":\"Not enough LTC.\"}", 200);
    Method apiMethod = PoloniexAuthenticated.class.getDeclaredMethod("moveOrder", String.class, ParamsDigest.class, SynchronizedValueFactory.class, String.class, String.class, String.class, Integer.class, Integer.class);
    RestMethodMetadata data = RestMethodMetadata.create(apiMethod, "", "");
    try {
        new JacksonResponseReader(new DefaultJacksonObjectMapperFactory().createObjectMapper(), false).read(invocationResult, data);
    } catch (PoloniexException e) {
        Assert.assertTrue(e.getMessage().startsWith("Not enough LTC."));
        throw e;
    }
}
Also used : DefaultJacksonObjectMapperFactory(si.mazi.rescu.serialization.jackson.DefaultJacksonObjectMapperFactory) Method(java.lang.reflect.Method) InvocationResult(si.mazi.rescu.InvocationResult) JacksonResponseReader(si.mazi.rescu.serialization.jackson.JacksonResponseReader) PoloniexException(org.knowm.xchange.poloniex.dto.PoloniexException) RestMethodMetadata(si.mazi.rescu.RestMethodMetadata) Test(org.junit.Test)

Example 3 with JacksonResponseReader

use of si.mazi.rescu.serialization.jackson.JacksonResponseReader in project XChange by knowm.

the class PoloniexBalanceTest method balanceRejectTest.

@Test(expected = PoloniexException.class)
public void balanceRejectTest() throws Exception {
    InvocationResult invocationResult = new InvocationResult("{\"error\":\"Invalid API key\\/secret pair.\"}", 200);
    Method apiMethod = PoloniexAuthenticated.class.getDeclaredMethod("returnCompleteBalances", String.class, ParamsDigest.class, SynchronizedValueFactory.class, String.class);
    RestMethodMetadata balances = RestMethodMetadata.create(apiMethod, "", "");
    try {
        new JacksonResponseReader(new DefaultJacksonObjectMapperFactory().createObjectMapper(), false).read(invocationResult, balances);
    } catch (PoloniexException e) {
        Assert.assertTrue(e.getMessage().startsWith("Invalid API key/secret pair."));
        throw e;
    }
}
Also used : DefaultJacksonObjectMapperFactory(si.mazi.rescu.serialization.jackson.DefaultJacksonObjectMapperFactory) Method(java.lang.reflect.Method) InvocationResult(si.mazi.rescu.InvocationResult) JacksonResponseReader(si.mazi.rescu.serialization.jackson.JacksonResponseReader) PoloniexException(org.knowm.xchange.poloniex.dto.PoloniexException) RestMethodMetadata(si.mazi.rescu.RestMethodMetadata) Test(org.junit.Test)

Example 4 with JacksonResponseReader

use of si.mazi.rescu.serialization.jackson.JacksonResponseReader in project XChange by knowm.

the class PoloniexOrderTest method buyRejectTest.

@Test(expected = PoloniexException.class)
public void buyRejectTest() throws Exception {
    InvocationResult invocationResult = new InvocationResult("{\"error\":\"Not enough LTC.\"}", 200);
    Method apiMethod = PoloniexAuthenticated.class.getDeclaredMethod("buy", String.class, ParamsDigest.class, SynchronizedValueFactory.class, String.class, String.class, String.class, Integer.class, Integer.class, Integer.class);
    RestMethodMetadata data = RestMethodMetadata.create(apiMethod, "", "");
    try {
        new JacksonResponseReader(new DefaultJacksonObjectMapperFactory().createObjectMapper(), false).read(invocationResult, data);
    } catch (PoloniexException e) {
        Assert.assertTrue(e.getMessage().startsWith("Not enough LTC."));
        throw e;
    }
}
Also used : DefaultJacksonObjectMapperFactory(si.mazi.rescu.serialization.jackson.DefaultJacksonObjectMapperFactory) Method(java.lang.reflect.Method) InvocationResult(si.mazi.rescu.InvocationResult) JacksonResponseReader(si.mazi.rescu.serialization.jackson.JacksonResponseReader) PoloniexException(org.knowm.xchange.poloniex.dto.PoloniexException) RestMethodMetadata(si.mazi.rescu.RestMethodMetadata) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)4 Test (org.junit.Test)4 PoloniexException (org.knowm.xchange.poloniex.dto.PoloniexException)4 InvocationResult (si.mazi.rescu.InvocationResult)4 RestMethodMetadata (si.mazi.rescu.RestMethodMetadata)4 DefaultJacksonObjectMapperFactory (si.mazi.rescu.serialization.jackson.DefaultJacksonObjectMapperFactory)4 JacksonResponseReader (si.mazi.rescu.serialization.jackson.JacksonResponseReader)4