use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.
the class ListRoleTest method serializeContractWithListRole.
@Test
public void serializeContractWithListRole() throws Exception {
Contract c = Contract.fromDslFile("./src/test_contracts/simple_root_contract.yml");
SimpleRole s1 = new SimpleRole("role");
ListRole listRole = new ListRole("owner", 1, Do.listOf(s1));
c.registerRole(listRole);
Binder b = BossBiMapper.serialize(c);
Contract c1 = DefaultBiMapper.deserialize(b);
assertEquals(c.getRole("owner"), c1.getRole("owner"));
}
use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.
the class ListRoleTest method serializeAny.
@Test
public void serializeAny() throws Exception {
SimpleRole s1 = new SimpleRole("owner");
SimpleRole s2 = new SimpleRole("owner2");
s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
s2.addKeyRecord(new KeyRecord(keys.get(2).getPublicKey()));
ListRole roleList = new ListRole("listAnyMode", ListRole.Mode.ANY, Do.listOf(s1, s2));
Binder serialized = DefaultBiMapper.serialize(roleList);
Role r1 = DefaultBiMapper.deserialize(serialized);
assertEquals(r1, roleList);
}
use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.
the class ListRoleTest method serializeAll.
@Test
public void serializeAll() throws Exception {
Contract c = new Contract();
SimpleRole s1 = new SimpleRole("owner");
s1.addRequiredReference("refName", Role.RequiredMode.ALL_OF);
s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
ListRole roleList = new ListRole("listAllMode", ListRole.Mode.ALL, Do.listOf(s1));
c.registerRole(s1);
c.registerRole(roleList);
Binder serialized = DefaultBiMapper.serialize(roleList);
Role r1 = DefaultBiMapper.deserialize(serialized);
assertEquals(r1, roleList);
}
use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.
the class RoleReferencesTest method serializeAll.
@Test
public void serializeAll() throws Exception {
SimpleRole sr = new SimpleRole("tr1");
sr.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
sr.addRequiredReference("ref", Role.RequiredMode.ALL_OF);
Binder serialized = DefaultBiMapper.serialize(sr);
Role r1 = DefaultBiMapper.deserialize(serialized);
assertEquals(sr, r1);
assertTrue(sr.getReferences(Role.RequiredMode.ANY_OF).isEmpty());
assertEquals(sr.getReferences(Role.RequiredMode.ALL_OF).size(), 1);
assertEquals(sr.getReferences(Role.RequiredMode.ALL_OF).iterator().next(), "ref");
}
use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.
the class RoleReferencesTest method serializeNone.
@Test
public void serializeNone() throws Exception {
SimpleRole sr = new SimpleRole("tr1");
sr.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
Binder serialized = DefaultBiMapper.serialize(sr);
Role r1 = DefaultBiMapper.deserialize(serialized);
assertEquals(sr, r1);
assertTrue(r1.getReferences(Role.RequiredMode.ANY_OF).isEmpty());
assertTrue(r1.getReferences(Role.RequiredMode.ALL_OF).isEmpty());
}
Aggregations