package io.zucchiniui.backend.scenario.views;

import io.zucchiniui.backend.scenario.domain.Scenario;
import io.zucchiniui.backend.shared.views.AbstractConfigurableMapper;
import ma.glasnost.orika.MapperFactory;

class ScenarioViewMapper extends AbstractConfigurableMapper {

    @Override
    protected void doConfigure(final MapperFactory factory) {
        factory.classMap(Scenario.class, ScenarioListItemView.class)
            .byDefault()
            .register();

        factory.classMap(Scenario.class, ScenarioHistoryItemView.class)
            .byDefault()
            .register();
    }

}

@@ -190,29 +190,180 @@
 t.orika.
-MapperFactory
+CustomConverter;%0Aimport ma.glasnost.orika.MapperFactory;%0Aimport ma.glasnost.orika.MappingContext;%0Aimport ma.glasnost.orika.metadata.Type;%0A%0Aimport java.util.Optional
 ;%0A%0Aclass
@@ -496,16 +496,125 @@
 tory) %7B%0A
+        factory.getConverterFactory().registerConverter(%22optionalOrNull%22, new OptionalOrNullConverter%3C%3E());%0A%0A
         
@@ -814,32 +814,32 @@
    .byDefault()%0A
-
             .reg
@@ -847,16 +847,505 @@
 ster();%0A
+%0A        factory.classMap(Scenario.class, FailedScenarioListItemView.class)%0A            .fieldMap(%22errorMessage%22).aToB().converter(%22optionalOrNull%22).add()%0A            .byDefault()%0A            .register();%0A    %7D%0A%0A    private static class OptionalOrNullConverter%3CT%3E extends CustomConverter%3COptional%3CT%3E, T%3E %7B%0A%0A        @Override%0A        public T convert(Optional%3CT%3E source, Type%3C? extends T%3E destinationType, MappingContext mappingContext) %7B%0A            return source.orElse(null);%0A        %7D%0A%0A
     %7D%0A%0A%7D

Fix error message mapping