varProps.put("branch", "dev");
RecordId masterRecordId = idGenerator.newRecordId("123");
RecordId recordId = idGenerator.newRecordId(masterRecordId, varProps);
Link link = Link.newBuilder().recordId(recordId).copyAll(false).create();
assertEquals(masterRecordId, link.getMasterRecordId());
assertEquals("USER.123.!*,branch=dev,lang=en", link.toString());
assertEquals(link, Link.fromString(link.toString(), idGenerator));
DataOutput dataOutput = new DataOutputImpl();
link.write(dataOutput);
assertEquals(link, Link.read(new DataInputImpl(dataOutput.toByteArray()), idGenerator));
assertEquals(2, link.getVariantProps().size());
assertEquals(Link.PropertyMode.SET, link.getVariantProps().get("lang").getMode());
assertEquals("en", link.getVariantProps().get("lang").getValue());
Map<String, String> ctxVarProps = new HashMap<String, String>();
varProps.put("a", "1");
varProps.put("b", "2");
varProps.put("lang", "nl");
RecordId ctx = idGenerator.newRecordId(idGenerator.newRecordId("0"), ctxVarProps);
RecordId resolved = link.resolve(ctx, idGenerator);
// Nothing from the context should have been copied
assertEquals(2, resolved.getVariantProperties().size());
assertEquals("en", resolved.getVariantProperties().get("lang"));
assertEquals("dev", resolved.getVariantProperties().get("branch"));