Search in sources :

Example 11 with ValueConverterException

use of com.canoo.platform.remoting.spi.converter.ValueConverterException in project dolphin-platform by canoo.

the class PeriodeConverterFactoryTest method testReconversion.

private void testReconversion(Converter converter, Period duration) {
    try {
        Object dolphinObject = converter.convertToDolphin(duration);
        assertNotNull(dolphinObject);
        Object reconvertedObject = converter.convertFromDolphin(dolphinObject);
        assertNotNull(reconvertedObject);
        assertEquals(reconvertedObject.getClass(), Period.class);
        Period reconvertedDuration = (Period) reconvertedObject;
        assertEquals(reconvertedDuration, duration);
    } catch (ValueConverterException e) {
        fail("Error in conversion", e);
    }
}
Also used : Period(java.time.Period) ValueConverterException(com.canoo.platform.remoting.spi.converter.ValueConverterException)

Example 12 with ValueConverterException

use of com.canoo.platform.remoting.spi.converter.ValueConverterException in project dolphin-platform by canoo.

the class ServerControllerActionCallBean method getParam.

public Object getParam(String name, Class<?> type) {
    final String internalName = PARAM_PREFIX + name;
    final Attribute valueAttribute = pm.getAttribute(internalName);
    if (valueAttribute == null) {
        throw new IllegalArgumentException(String.format("Invoking RemotingAction requires parameter '%s', but it was not withContent", name));
    }
    try {
        return converters.getConverter(type).convertFromDolphin(valueAttribute.getValue());
    } catch (ValueConverterException e) {
        throw new MappingException("Error in conversion", e);
    }
}
Also used : Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) ValueConverterException(com.canoo.platform.remoting.spi.converter.ValueConverterException) MappingException(com.canoo.dp.impl.remoting.MappingException)

Aggregations

ValueConverterException (com.canoo.platform.remoting.spi.converter.ValueConverterException)12 Converters (com.canoo.dp.impl.remoting.Converters)5 Converter (com.canoo.platform.remoting.spi.converter.Converter)5 Test (org.testng.annotations.Test)5 MappingException (com.canoo.dp.impl.remoting.MappingException)2 CallActionCommand (com.canoo.dp.impl.remoting.commands.CallActionCommand)1 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)1 ControllerActionException (com.canoo.platform.remoting.client.ControllerActionException)1 Param (com.canoo.platform.remoting.client.Param)1 Duration (java.time.Duration)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Period (java.time.Period)1 ZonedDateTime (java.time.ZonedDateTime)1 CompletableFuture (java.util.concurrent.CompletableFuture)1