### Question:
SplitJoinPermission extends Permission { @Override public void deserialize(Binder data, BiDeserializer deserializer) { super.deserialize(data, deserializer); initFromParams(); } SplitJoinPermission(Role role, Binder params); private  SplitJoinPermission(); @Override void deserialize(Binder data, BiDeserializer deserializer); @Override void checkChangesQuantized(Contract contract, Contract changed, Map<String, Delta> stateChanges, Set<Contract> revokingItems, Collection<PublicKey> keys); boolean validateMergeFields(Contract changed, Contract c);  }### Answer:
@Test public void shouldNotSplitWithWrongDataAmountSerialize() throws Exception { Contract c = createCoin(); c.addSignerKeyFromFile(PRIVATE_KEY_PATH); sealCheckTrace(c, true); Contract c2 = c.split(1)[0]; sealCheckTrace(c2, true); Binder sd2 = DefaultBiMapper.serialize(c2); Binder state = (Binder) sd2.get("state"); assertNotNull(state); assertTrue(state.size() > 0); Binder data = (Binder) state.get("data"); assertNotNull(data); assertTrue(data.size() > 0); data.remove(FIELD_NAME); Contract dc2 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc2, false); }
@Test public void shouldNotSplitWithWrongCreatedBySerialize() throws Exception { Contract c = createCoin(); c.addSignerKeyFromFile(PRIVATE_KEY_PATH); sealCheckTrace(c, true); Contract c2 = c.split(1)[0]; sealCheckTrace(c2, true); Binder sd2 = DefaultBiMapper.serialize(c2); Binder state = (Binder) sd2.get("state"); assertNotNull(state); assertTrue(state.size() > 0); state.set("createdBy", "other"); Contract dc2 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc2, false); state.set("createdBy", "owner"); Contract dc3 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc3, false); state.remove("createdBy"); Contract dc4 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc4, false); }
@Test public void shouldNotSplitWithWrongOriginSerialize() throws Exception { Contract c = createCoin(); c.addSignerKeyFromFile(PRIVATE_KEY_PATH); sealCheckTrace(c, true); Contract c2 = c.split(1)[0]; sealCheckTrace(c2, true); Binder sd2 = DefaultBiMapper.serialize(c2); Binder state = (Binder) sd2.get("state"); assertNotNull(state); assertTrue(state.size() > 0); HashId origin = HashId.withDigest(Do.randomNegativeBytes(64)); Binder originB = DefaultBiMapper.serialize(origin); state.set("origin", originB); Contract dc2 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc2, false); state.remove("origin"); Contract dc3 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc3, false); }
@Test public void shouldNotSplitWithWrongParentSerialize() throws Exception { Contract c = createCoin(); c.addSignerKeyFromFile(PRIVATE_KEY_PATH); sealCheckTrace(c, true); Contract c2 = c.split(1)[0]; sealCheckTrace(c2, true); Binder sd2 = DefaultBiMapper.serialize(c2); Binder state = (Binder) sd2.get("state"); assertNotNull(state); assertTrue(state.size() > 0); HashId parent = HashId.withDigest(Do.randomNegativeBytes(64)); Binder parentB = DefaultBiMapper.serialize(parent); state.set("parent", parentB); Contract dc2 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc2, false); state.remove("parent"); Contract dc3 = DefaultBiMapper.deserialize(sd2); sealCheckTrace(dc3, false); }