private boolean isOriginReferenceExists(HashId origin) { return getReferences().values().stream().anyMatch(ref -> ref.getConditions().getArray(Reference.conditionsModeType.all_of.name()).stream().anyMatch(cond -> isOriginCondition(cond, origin))); }
ArrayList conditions = ref.getConditions().getArray(Reference.conditionsModeType.all_of.name()); conditions.forEach(condition -> { HashId o = null; } else { Reference reference = getReferences().values().stream().filter(ref -> ref.getConditions().getArray(Reference.conditionsModeType.all_of.name()).stream().anyMatch(cond -> isOriginCondition(cond, origin))).collect(Collectors.toList()).get(0); if(reference.matchingItems.isEmpty() && originContracts.containsKey(origin))
if ((((rm.transactional_id != null && neighbour.transactional != null && rm.transactional_id.equals(neighbour.transactional.id)) || (rm.contract_id != null && rm.contract_id.equals(neighbour.id))) && checkOneReference(rm, neighbour)) || (rm.getConditions().size() > 0)) // new format of reference with conditions, transactional_id - optional if (rm.isMatchingWith(neighbour, neighbours)) { rm.addMatchingItem(neighbour);
Binder conditions = contract1.getReferences().get("ref_string").getConditions(); List<Object> condList = conditions.getList(all_of.name(), null); contract1.getReferences().get("ref_string").setConditions(conditions); conditions = contract1.getReferences().get("ref_time").getConditions(); condList = conditions.getList(all_of.name(), null);
Binder conditions = refContract.getReferences().get("test_ref4").getConditions(); List<Object> condList = conditions.getList(all_of.name(), null); conditions = refContract.getReferences().get("test_ref3").getConditions(); condList = conditions.getList(all_of.name(), null); assertEquals(parsed.getIntOrThrow("operator"), 3); conditions = refContract.getReferences().get("test_ref4").getConditions(); condList = conditions.getList(all_of.name(), null);
/** * Check serialization and deserialization contract with references * @throws Exception */ @Test public void checkReferenceSerialization() throws Exception { Contract contract = Contract.fromDslFile(rootPath + "simple_root_contract_with_references.yml"); assertEquals(contract.findReferenceByName("ref_cont").getComment(), "ref_comment"); contract.findReferenceByName("ref_cont3").setComment("ref_comment3"); contract.seal(); Binder b = BossBiMapper.serialize(contract); Contract desContract = DefaultBiMapper.deserialize(b); assertEquals(desContract.findReferenceByName("ref_cont").getComment(), "ref_comment"); assertEquals(desContract.findReferenceByName("ref_cont3").getComment(), "ref_comment3"); assertNull(desContract.findReferenceByName("ref_cont2").getComment()); for (Reference ref: contract.getReferences().values()) { Reference desRef = desContract.findReferenceByName(ref.getName()); assertTrue(desRef != null); assertEquals(ref.getConditions(), desRef.getConditions()); } }
Reference desRef = checkingContract.findReferenceByName(ref.getName()); assertTrue(desRef != null); assertEquals(ref.getConditions(), desRef.getConditions());