polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niclas Hedhman (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (POLYGENE-142) Enum Property in EntityComposite serialization error
Date Sat, 28 Apr 2018 07:47:00 GMT

     [ https://issues.apache.org/jira/browse/POLYGENE-142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Niclas Hedhman closed POLYGENE-142.
-----------------------------------

> Enum Property in EntityComposite serialization error
> ----------------------------------------------------
>
>                 Key: POLYGENE-142
>                 URL: https://issues.apache.org/jira/browse/POLYGENE-142
>             Project: Polygene
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Mingzhou Zhuang
>            Assignee: Niclas Hedhman
>            Priority: Critical
>              Labels: bug
>             Fix For: 3.0.0
>
>
> TestValue as value composite, it's ok.
> TestValue as entity composite, fail?
> {code}
> public enum TestEnum {
>     A, B, C, D
> }
> public interface TestValue {
>     Property<Double> price();
>     Property<TestEnum> testenum();
> }
> public static void main(String[] args) throws ActivationException, AssemblyException,
UnitOfWorkCompletionException, JsonProcessingException {
>         SingletonAssembler assembler = new SingletonAssembler() {
>             @Override
>             public void assemble(ModuleAssembly module_)
>                     throws AssemblyException {
>                 module_.values(TestValue.class);    // Value
>                 module_.entities(TestValue.class);  // Entity
>                 module_.services(JacksonValueSerializationService.class)
>                         .taggedWith(ValueSerialization.Formats.JSON)
>                         .visibleIn(Visibility.application)
>                         .instantiateOnStartup();
>                 module_.services(MemoryEntityStoreService.class);
>                 module_.services(UuidIdentityGeneratorService.class);
>             }
>         };
>         Module module = assembler.module();
>         ValueSerialization serialization = module.findService(ValueSerialization.class)
>                 .get();
>         TestValue value;
>         {
>             ValueBuilder<TestValue> builder = module.newValueBuilder(TestValue.class);
>             builder.prototype().price().set(23.45);
>             builder.prototype().testenum().set(TestEnum.B);
>             value = builder.newInstance();
>             _sLogger.info("value {}, {}, {}", value, value.price().get(), value.testenum().get());
>             System.out.println(serialization.serialize(value)); // ok
>             value = serialization.deserialize(TestValue.class, serialization.serialize(value));
// ok
>             _sLogger.info("de value {}, {}, {}", value, value.price().get(), value.testenum().get());
>         }
>         {
>             String valueId = "abcdefg";
>             {
>                 UnitOfWork uow = module.newUnitOfWork(UsecaseBuilder.newUsecase("create"));
>                 EntityBuilder<TestValue> builder = uow.newEntityBuilder(TestValue.class,
valueId);
>                 builder.instance().price().set(45.67);
>                 builder.instance().testenum().set(TestEnum.A);
>                 value = builder.newInstance();
>                 try {
>                     uow.complete();
>                 } catch (Exception e_) {
>                     uow.discard();
>                     e_.printStackTrace();
>                 }
>             }
>             {
>                 UnitOfWork uow = module.newUnitOfWork(UsecaseBuilder.newUsecase("create"));
>                 value = uow.get(TestValue.class, valueId);
>                 System.out.println(value.price().get());
>                 System.out.println(value.testenum().get()); // FAIL
>                 uow.discard();
>             }
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message