@Test public void addressesExist_addressInLocalDB_shouldReturnHashAndTrue() { AddressBulkRequest addressBulkRequest = AddressTestUtils.generateAddressBulkRequest( addressInLocalAddressesCollection.getHash()); AddressesExistsResponse actualResponse = addressService.addressesCheckExistenceAndRequestHistoryNode(addressBulkRequest); AddressesExistsResponse expectedResponse = AddressTestUtils.generateExpectedResponse( AddressTestUtils.initMapWithHashes( addressInLocalAddressesCollection.getHash()), Boolean.TRUE); Assert.assertTrue(AddressTestUtils.equals(expectedResponse, actualResponse)); }
public AddressesExistsResponse addressesCheckExistenceAndRequestHistoryNode(AddressBulkRequest addressRequest) { List<Hash> addressHashes = addressRequest.getAddresses(); LinkedHashMap<String, Boolean> addressHashToFoundStatusMap = new LinkedHashMap<>(); String historyNodeHttpAddress = getHistoryNodeHttpAddress(); addressHashes.removeIf(addressHash -> { if (addresses.getByHash(addressHash) != null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.TRUE); return true; } RequestedAddressHashData requestedAddressHashData = requestedAddressHashes.getByHash(addressHash); if (validateRequestedAddressHashExistsAndRelevant(requestedAddressHashData) || historyNodeHttpAddress == null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.FALSE); return true; } addressHashToFoundStatusMap.put(addressHash.toHexString(), null); return false; }); if (!addressHashes.isEmpty()) { fillUnknownAddressesFromHistoryResponse(addressHashes, addressHashToFoundStatusMap, historyNodeHttpAddress); } return new AddressesExistsResponse(addressHashToFoundStatusMap); }
AddressService extends BaseNodeAddressService { public AddressesExistsResponse addressesCheckExistenceAndRequestHistoryNode(AddressBulkRequest addressRequest) { List<Hash> addressHashes = addressRequest.getAddresses(); LinkedHashMap<String, Boolean> addressHashToFoundStatusMap = new LinkedHashMap<>(); String historyNodeHttpAddress = getHistoryNodeHttpAddress(); addressHashes.removeIf(addressHash -> { if (addresses.getByHash(addressHash) != null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.TRUE); return true; } RequestedAddressHashData requestedAddressHashData = requestedAddressHashes.getByHash(addressHash); if (validateRequestedAddressHashExistsAndRelevant(requestedAddressHashData) || historyNodeHttpAddress == null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.FALSE); return true; } addressHashToFoundStatusMap.put(addressHash.toHexString(), null); return false; }); if (!addressHashes.isEmpty()) { fillUnknownAddressesFromHistoryResponse(addressHashes, addressHashToFoundStatusMap, historyNodeHttpAddress); } return new AddressesExistsResponse(addressHashToFoundStatusMap); } }
AddressService extends BaseNodeAddressService { public AddressesExistsResponse addressesCheckExistenceAndRequestHistoryNode(AddressBulkRequest addressRequest) { List<Hash> addressHashes = addressRequest.getAddresses(); LinkedHashMap<String, Boolean> addressHashToFoundStatusMap = new LinkedHashMap<>(); String historyNodeHttpAddress = getHistoryNodeHttpAddress(); addressHashes.removeIf(addressHash -> { if (addresses.getByHash(addressHash) != null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.TRUE); return true; } RequestedAddressHashData requestedAddressHashData = requestedAddressHashes.getByHash(addressHash); if (validateRequestedAddressHashExistsAndRelevant(requestedAddressHashData) || historyNodeHttpAddress == null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.FALSE); return true; } addressHashToFoundStatusMap.put(addressHash.toHexString(), null); return false; }); if (!addressHashes.isEmpty()) { fillUnknownAddressesFromHistoryResponse(addressHashes, addressHashToFoundStatusMap, historyNodeHttpAddress); } return new AddressesExistsResponse(addressHashToFoundStatusMap); }  }
AddressService extends BaseNodeAddressService { public AddressesExistsResponse addressesCheckExistenceAndRequestHistoryNode(AddressBulkRequest addressRequest) { List<Hash> addressHashes = addressRequest.getAddresses(); LinkedHashMap<String, Boolean> addressHashToFoundStatusMap = new LinkedHashMap<>(); String historyNodeHttpAddress = getHistoryNodeHttpAddress(); addressHashes.removeIf(addressHash -> { if (addresses.getByHash(addressHash) != null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.TRUE); return true; } RequestedAddressHashData requestedAddressHashData = requestedAddressHashes.getByHash(addressHash); if (validateRequestedAddressHashExistsAndRelevant(requestedAddressHashData) || historyNodeHttpAddress == null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.FALSE); return true; } addressHashToFoundStatusMap.put(addressHash.toHexString(), null); return false; }); if (!addressHashes.isEmpty()) { fillUnknownAddressesFromHistoryResponse(addressHashes, addressHashToFoundStatusMap, historyNodeHttpAddress); } return new AddressesExistsResponse(addressHashToFoundStatusMap); }  boolean addAddress(Hash addressHash); AddressesExistsResponse addressesCheckExistenceAndRequestHistoryNode(AddressBulkRequest addressRequest); }
AddressService extends BaseNodeAddressService { public AddressesExistsResponse addressesCheckExistenceAndRequestHistoryNode(AddressBulkRequest addressRequest) { List<Hash> addressHashes = addressRequest.getAddresses(); LinkedHashMap<String, Boolean> addressHashToFoundStatusMap = new LinkedHashMap<>(); String historyNodeHttpAddress = getHistoryNodeHttpAddress(); addressHashes.removeIf(addressHash -> { if (addresses.getByHash(addressHash) != null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.TRUE); return true; } RequestedAddressHashData requestedAddressHashData = requestedAddressHashes.getByHash(addressHash); if (validateRequestedAddressHashExistsAndRelevant(requestedAddressHashData) || historyNodeHttpAddress == null) { addressHashToFoundStatusMap.put(addressHash.toHexString(), Boolean.FALSE); return true; } addressHashToFoundStatusMap.put(addressHash.toHexString(), null); return false; }); if (!addressHashes.isEmpty()) { fillUnknownAddressesFromHistoryResponse(addressHashes, addressHashToFoundStatusMap, historyNodeHttpAddress); } return new AddressesExistsResponse(addressHashToFoundStatusMap); }  boolean addAddress(Hash addressHash); AddressesExistsResponse addressesCheckExistenceAndRequestHistoryNode(AddressBulkRequest addressRequest);  }