method2testcases
stringlengths
118
6.63k
### Question: ServiceContext { public synchronized boolean isAvailable() { Service service = this.service; return service != null && !CollectionValues.isNullOrEmpty(service.getInstances()); } ServiceContext(DiscoveryConfig discoveryConfig); DiscoveryConfig getDiscoveryConfig(); synchronized Service newService(); synchr...
### Question: GroupDao { protected void insertOrUpdate(final GroupModel... groups) { insertOrUpdate(Lists.newArrayList(groups)); } private GroupDao(); List<GroupModel> query(); List<GroupModel> select(GroupModel filter); List<GroupModel> select(List<Long> groupIds); static final GroupDao INSTANCE; }### Answer: @Test p...
### Question: GroupDao { protected void delete(final Long... ids) { delete(Lists.newArrayList(ids)); } private GroupDao(); List<GroupModel> query(); List<GroupModel> select(GroupModel filter); List<GroupModel> select(List<Long> groupIds); static final GroupDao INSTANCE; }### Answer: @Test public void testDelete() { Gr...
### Question: GroupDao { public List<GroupModel> select(GroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("service_id=?", filter.getServiceId()); conditio...
### Question: ServiceInstanceLogDao { protected void insert(final ServiceInstanceLogModel... logs) { if ((logs == null) || (logs.length == 0)) { return; } this.insert(Lists.newArrayList(logs)); } private ServiceInstanceLogDao(); List<ServiceInstanceLog> select(ServiceInstanceLogModel filter); List<ServiceInstanceLog> ...
### Question: GroupTagDao { public List<GroupTagModel> query() { return DataConfig.jdbcTemplate().query("select group_id, tag, value from service_group_tag", new RowMapper<GroupTagModel>() { @Override public GroupTagModel mapRow(ResultSet rs, int i) throws SQLException { GroupTagModel tag = new GroupTagModel(); tag.set...
### Question: GroupTagDao { public void delete(GroupTagModel filter) { ValueCheckers.notNull(filter, "filter"); final Map<String, String> conditions = Maps.newHashMap(); conditions.put("group_id=?", filter.getGroupId() == null ? null : Long.toString(filter.getGroupId())); conditions.put("tag=?", filter.getTag()); condi...
### Question: GroupTagDao { public void insertOrUpdate(GroupTagModel... models) { insertOrUpdate(Lists.newArrayList(models)); } private GroupTagDao(); List<GroupTagModel> query(); void delete(GroupTagModel filter); void insertOrUpdate(GroupTagModel... models); void insertOrUpdate(final List<GroupTagModel> models); sta...
### Question: GroupTagLogDao { public void insert(final GroupTagLogModel... logs) { if ((logs == null) || (logs.length == 0)) { return; } this.insert(Lists.newArrayList(logs)); } private GroupTagLogDao(); List<GroupTagLog> query(final String condition, final Object... args); void insert(final GroupTagLogModel... logs)...
### Question: RouteRuleDao { protected void insertOrUpdate(RouteRuleModel... models) { insertOrUpdate(Lists.newArrayList(models)); } List<RouteRuleModel> query(); List<RouteRuleModel> select(RouteRuleModel filter); List<RouteRuleModel> select(List<Long> groupIds); static final RouteRuleDao INSTANCE; }### Answer: @Test...
### Question: RouteRuleDao { protected void delete(final Long... ids) { delete(Lists.newArrayList(ids)); } List<RouteRuleModel> query(); List<RouteRuleModel> select(RouteRuleModel filter); List<RouteRuleModel> select(List<Long> groupIds); static final RouteRuleDao INSTANCE; }### Answer: @Test public void testDelete() ...
### Question: DiscoveryClientImpl implements DiscoveryClient { @Override public Service getService(final DiscoveryConfig discoveryConfig) { DiscoveryConfigChecker.DEFAULT.check(discoveryConfig, "discoveryConfig"); return serviceRepository.getService(discoveryConfig); } DiscoveryClientImpl(final String clientId, final A...
### Question: RouteRuleDao { public List<RouteRuleModel> select(RouteRuleModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("service_id=?", filter.getServiceId(...
### Question: ServiceInstanceDao { public List<ServiceInstanceModel> query() { final String sql = "SELECT service_id, instance_id, ip, machine_name, metadata, port, protocol, region_id, zone_id, healthy_check_url, url, group_id from service_instance"; return DataConfig.jdbcTemplate().query(sql, new RowMapper<ServiceIns...
### Question: ServiceInstanceDao { protected void delete(final Long... ids) { delete(Lists.newArrayList(ids)); } private ServiceInstanceDao(); List<ServiceInstanceModel> query(); List<ServiceInstanceModel> select(ServiceInstanceModel filter); List<ServiceInstanceModel> select(List<Long> groupIds); static final Service...
### Question: ServiceInstanceDao { protected void deleteByFilters(final List<ServiceInstanceModel> filters) { checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_instance where service_id = ? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBa...
### Question: ServiceInstanceDao { protected void insertOrUpdate(final ServiceInstanceModel... groupInstances) { insertOrUpdate(Lists.newArrayList(groupInstances)); } private ServiceInstanceDao(); List<ServiceInstanceModel> query(); List<ServiceInstanceModel> select(ServiceInstanceModel filter); List<ServiceInstanceMo...
### Question: BusinessDao { @Transactional public void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete) { checkOperationContextArgument(operationContext); List<GroupOperationModel> groupOperation = Lists .newArrayList(new GroupOperationModel(groupDao.generateGrou...
### Question: BusinessDao { public void insertOrUpdateRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups) { checkOperationContextArgument(operationContext); routeRuleGroupDao.insertOrUpdate(routeRuleGroups); routeRuleGroupLogDao.insert(RouteRuleGroups.newRouteRuleGroupLogs(oper...
### Question: GroupOperationDao { public List<GroupOperationModel> query() { return DataConfig.jdbcTemplate().query("select group_id, operation from service_group_operation", new RowMapper<GroupOperationModel>() { @Override public GroupOperationModel mapRow(ResultSet rs, int i) throws SQLException { GroupOperationModel...
### Question: GroupOperationDao { protected void delete(GroupOperationModel groupOperation) { delete(Lists.newArrayList(groupOperation)); } private GroupOperationDao(); List<GroupOperationModel> query(); static final GroupOperationDao INSTANCE; }### Answer: @Test public void testDelete() throws Exception { GroupOperat...
### Question: DiscoveryClientImpl implements DiscoveryClient { @Override public void registerServiceChangeListener(final DiscoveryConfig discoveryConfig, final ServiceChangeListener listener) { DiscoveryConfigChecker.DEFAULT.check(discoveryConfig, "discoveryConfig"); NullArgumentChecker.DEFAULT.check(listener, "listene...
### Question: GroupOperationDao { protected void insertOrUpdate(GroupOperationModel... operationModels) { insertOrUpdate(Lists.newArrayList(operationModels)); } private GroupOperationDao(); List<GroupOperationModel> query(); static final GroupOperationDao INSTANCE; }### Answer: @Test public void testInsertOrUpdate() t...
### Question: GroupInstanceDao { protected void delete(final Long... ids) { delete(Lists.newArrayList(ids)); } private GroupInstanceDao(); List<GroupInstanceModel> query(); List<GroupInstanceModel> select(GroupInstanceModel filter); List<GroupInstanceModel> select(List<Long> groupIds); static final GroupInstanceDao IN...
### Question: GroupInstanceDao { protected void deleteByFilters(final List<GroupInstanceModel> filters){ checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_group_instance where group_id = ? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBat...
### Question: GroupInstanceDao { public List<GroupInstanceModel> select(GroupInstanceModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("group_id=?", filter.get...
### Question: RouteRuleGroupDao { protected void insertOrUpdate(final RouteRuleGroupModel... models) { insertOrUpdate(Lists.newArrayList(models)); } List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); Li...
### Question: RouteRuleGroupDao { protected void insert(final RouteRuleGroupModel... models) { insert(Lists.newArrayList(models)); } List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); List<RouteRuleGrou...
### Question: RouteRuleGroupDao { protected void delete(final Long... ids) { delete(Lists.newArrayList(ids)); } List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); List<RouteRuleGroupModel> select(List<L...
### Question: RouteRuleGroupDao { public List<RouteRuleGroupModel> select(RouteRuleGroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, Long> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId()); conditions.put("route_rule_id=?", filter.getRouteRuleId()); conditions.put("group_id=...
### Question: RouteRuleGroupDao { protected void release(final List<RouteRuleGroupModel> models) { checkReleaseArgument(models); DataConfig.jdbcTemplate().batchUpdate("update service_route_rule_group set weight = unreleased_weight where route_rule_id=? and group_id=?", new BatchPreparedStatementSetter() { @Override pub...
### Question: RouteRuleGroupDao { protected void publish(final RouteRuleGroupModel... models) { publish(Lists.newArrayList(models)); } List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); List<RouteRuleGr...
### Question: ArtemisDiscoveryHttpClient extends ArtemisHttpClient { public Service getService(final DiscoveryConfig discoveryConfig) { Preconditions.checkArgument(discoveryConfig != null, "discoveryConfig"); final List<Service> services = getServices(Lists.newArrayList(discoveryConfig)); if (services.size() > 0) { ret...
### Question: GroupOperationLogDao { public void insert(final GroupOperationLogModel... logs) { if ((logs == null) || (logs.length == 0)) { return; } this.insert(Lists.newArrayList(logs)); } private GroupOperationLogDao(); List<GroupOperationLog> select(GroupOperationLogModel filter, Boolean complete); List<GroupOpera...
### Question: RouteRuleGroupLogDao { public void insert(final RouteRuleGroupLogModel... logs) { if ((logs == null) || (logs.length == 0)) { return; } this.insert(Lists.newArrayList(logs)); } private RouteRuleGroupLogDao(); List<RouteRuleGroupLog> select(RouteRuleGroupLogModel filter); List<RouteRuleGroupLog> query(fin...
### Question: GroupInstanceLogDao { protected void insert(final GroupInstanceLogModel... logs) { if ((logs == null) || (logs.length == 0)) { return; } this.insert(Lists.newArrayList(logs)); } private GroupInstanceLogDao(); List<GroupInstanceLog> select(GroupInstanceLogModel filter); List<GroupInstanceLog> query(final ...
### Question: GroupLogDao { public void insert(final GroupLogModel... logs) { if ((logs == null) || (logs.length == 0)) { return; } this.insert(Lists.newArrayList(logs)); } private GroupLogDao(); List<GroupLog> select(GroupLogModel filter); List<GroupLog> query(final String condition, final List<Object> args); void in...
### Question: ZoneOperationLogDao { public void insert(final ZoneOperationLogModel... logs) { if ((logs == null) || (logs.length == 0)) { return; } this.insert(Lists.newArrayList(logs)); } private ZoneOperationLogDao(); List<ZoneOperationLog> select(ZoneOperationLogModel filter, Boolean complete); List<ZoneOperationLo...
### Question: ZoneOperationDao { public void insertOrUpdate(ZoneOperationModel... operationModels) { insertOrUpdate(Lists.newArrayList(operationModels)); } private ZoneOperationDao(); List<ZoneOperationModel> query(); void delete(final ZoneOperationModel... zoneOperations); void delete(final List<ZoneOperationModel> z...
### Question: ZoneOperationDao { public void delete(final ZoneOperationModel... zoneOperations) { delete(Lists.newArrayList(zoneOperations)); } private ZoneOperationDao(); List<ZoneOperationModel> query(); void delete(final ZoneOperationModel... zoneOperations); void delete(final List<ZoneOperationModel> zoneOperation...
### Question: ZoneOperationDao { public List<ZoneOperationModel> select(ZoneOperationModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("service_id=?", filter.g...
### Question: SearchTree { public V get(List<K> cascadingFactors) { if (CollectionValues.isNullOrEmpty(cascadingFactors)) { return value; } List<K> factors = Lists.newArrayList(cascadingFactors); SearchTree<K, V> g = children.get(factors.remove(0)); if (g == null) { return defaultChildrenValue; } return g.get(factors);...
### Question: SearchTree { public void add(List<K> cascadingFactors, V value) { if (CollectionValues.isNullOrEmpty(cascadingFactors)) { this.value = value; return; } List<K> factors = Lists.newArrayList(cascadingFactors); K factor = factors.remove(0); ValueCheckers.notNull(factor, "factor"); SearchTree<K, V> child = ch...
### Question: SearchTree { public V first(List<K> cascadingFactors) { if (value != null || CollectionValues.isNullOrEmpty(cascadingFactors)) { return value; } List<K> factors = Lists.newArrayList(cascadingFactors); SearchTree<K, V> g = children.get(factors.remove(0)); if (g == null) { return defaultChildrenValue; } ret...
### Question: ServiceGroups { public static int fixWeight(Integer weight) { if (weight == null || weight < MIN_WEIGHT_VALUE) { return DEFAULT_WEIGHT_VALUE; } if (weight > MAX_WEIGHT_VALUE) { return MAX_WEIGHT_VALUE; } return weight; } private ServiceGroups(); static int fixWeight(Integer weight); static boolean isDefa...
### Question: ArtemisDiscoveryHttpClient extends ArtemisHttpClient { public List<Service> getServices(final List<DiscoveryConfig> discoveryConfigs) { Preconditions.checkArgument(!CollectionUtils.isEmpty(discoveryConfigs), "discoveryConfigs should not be null or empty"); final LookupRequest request = new LookupRequest(d...
### Question: ServiceDiscovery { protected void reload(DiscoveryConfig... configs) { reload(Lists.newArrayList(configs)); } ServiceDiscovery(final ServiceRepository serviceRepository, final ArtemisClientConfig config); void registerDiscoveryConfig(DiscoveryConfig config); Service getService(DiscoveryConfig config); }#...
### Question: BtpRuntimeException extends RuntimeException { public BtpError toBtpError(long requestId) { return toBtpError(requestId, new BtpSubProtocols()); } BtpRuntimeException(); BtpRuntimeException(BtpErrorCode code, String message); BtpRuntimeException(BtpErrorCode code, String message, Throwable cause); BtpR...
### Question: IlpOverHttpLink extends AbstractLink<IlpOverHttpLinkSettings> implements Link<IlpOverHttpLinkSettings> { public void testConnection() { try { final Request okHttpRequest = this.constructSendPacketRequest(UNFULFILLABLE_PACKET); try (Response response = okHttpClient.newCall(okHttpRequest).execute()) { if (r...
### Question: LinkSettingsUtils { public static Map<String, Object> flattenSettings(Map<String, Object> settings) { return flattenSettings("", settings); } static Map<String, Object> flattenSettings(Map<String, Object> settings); static Optional<IlpOverHttpLinkSettings.AuthType> getIncomingAuthType(Map<String, Object>...
### Question: LinkSettingsUtils { public static Optional<IlpOverHttpLinkSettings.AuthType> getIncomingAuthType(Map<String, Object> customSettings) { return Optional.ofNullable(flattenSettings(customSettings).get(IncomingLinkSettings.HTTP_INCOMING_AUTH_TYPE)) .map(Object::toString) .map(String::toUpperCase) .map(IlpOver...
### Question: LinkSettingsUtils { public static Optional<IlpOverHttpLinkSettings.AuthType> getOutgoingAuthType(Map<String, Object> customSettings) { return Optional.ofNullable(flattenSettings(customSettings).get(OutgoingLinkSettings.HTTP_OUTGOING_AUTH_TYPE)) .map(Object::toString) .map(String::toUpperCase) .map(IlpOver...
### Question: JwtHs256BearerTokenSupplier implements BearerTokenSupplier { @Override public String get() { try { return this.ilpOverHttpAuthTokens.get(outgoingLinkSettings.jwtAuthSettings().get().tokenSubject()); } catch (ExecutionException e) { throw new RuntimeException(e); } } JwtHs256BearerTokenSupplier( fina...
### Question: AsnIldcpResponsePacketDataCodec extends AsnSequenceCodec<IldcpResponsePacket> { @Override public IldcpResponsePacket decode() { final IldcpResponse ildcpResponse; try { ildcpResponse = IldcpCodecContextFactory.oer() .read(IldcpResponse.class, new ByteArrayInputStream(getValueAt(1))); } catch (IOException ...
### Question: DateUtils { public static Instant now() { return Instant.now().truncatedTo(ChronoUnit.MILLIS); } static Instant now(); }### Answer: @Test public void now() { for (int i = 0; i < 100; i++) { long micros = DateUtils.now().get(ChronoField.MICRO_OF_SECOND); assertThat(micros % 1000).isEqualTo(0); } }
### Question: InterledgerRustNodeClient { public RustNodeAccount createAccount(RustNodeAccount rustNodeAccount) throws IOException { return execute(requestBuilder() .url(baseUrl.newBuilder().addPathSegment("accounts").build()) .post(RequestBody.create(objectMapper.writeValueAsString(rustNodeAccount), JSON)) .build(), R...
### Question: InterledgerRustNodeClient { public BigDecimal getBalance(String accountName) throws SpspClientException { return execute(requestBuilder() .url( baseUrl.newBuilder().addPathSegment("accounts").addPathSegment(accountName).addPathSegment("balance").build() ) .get() .build(), BalanceResponse.class) .getBalanc...
### Question: SimpleSpspClient implements SpspClient { @Override public StreamConnectionDetails getStreamConnectionDetails(final PaymentPointer paymentPointer) throws InvalidReceiverClientException { Objects.requireNonNull(paymentPointer); return getStreamConnectionDetails(paymentPointerResolver.resolveHttpUrl(paymentP...
### Question: IldcpResponsePacketMapper { public final T map(final InterledgerResponsePacket responsePacket) { Objects.requireNonNull(responsePacket); if (InterledgerFulfillPacket.class.isAssignableFrom(responsePacket.getClass())) { return mapFulfillPacket((IldcpResponsePacket) responsePacket); } else if (InterledgerRe...
### Question: AsnIldcpPacketCodec extends AsnSequenceCodec<T> { protected void onTypeIdChanged(int typeId) { switch (typeId) { case IldcpPacketTypes.REQUEST: setCodecAt(1, new AsnOpenTypeCodec<>(new AsnIldcpRequestPacketDataCodec())); return; case IldcpPacketTypes.RESPONSE: setCodecAt(1, new AsnOpenTypeCodec<>(new AsnI...
### Question: IldcpResponsePacketHandler { public final void handle(final InterledgerResponsePacket responsePacket) { Objects.requireNonNull(responsePacket); if (IldcpResponsePacket.class.isAssignableFrom(responsePacket.getClass())) { handleIldcpResponsePacket((IldcpResponsePacket) responsePacket); } else if (Interledg...
### Question: AimdCongestionController implements CongestionController { @Override public boolean hasInFlight() { return is(this.amountInFlight.get()).greaterThan(UnsignedLong.ZERO); } AimdCongestionController(); AimdCongestionController( final UnsignedLong startAmount, final UnsignedLong increaseAmount, final B...
### Question: AsnIldcpRequestPacketDataCodec extends AsnSequenceCodec<IldcpRequestPacket> { @Override public void encode(IldcpRequestPacket value) { setValueAt(0, value.getAmount()); setValueAt(1, value.getExpiresAt()); setValueAt(2, value.getExecutionCondition()); setValueAt(3, value.getDestination()); setValueAt(4, v...
### Question: StreamConnectionManager { public StreamConnection openConnection(final StreamConnectionId streamConnectionId) { Objects.requireNonNull(streamConnectionId); return connections.computeIfAbsent(streamConnectionId, StreamConnection::new); } StreamConnection openConnection(final StreamConnectionId streamConne...
### Question: StreamConnectionManager { public Optional<StreamConnection> closeConnection(final StreamConnectionId streamConnectionId) { Objects.requireNonNull(streamConnectionId); return Optional.ofNullable(connections.get(streamConnectionId)) .map(connectionToClose -> { connectionToClose.closeConnection(); return con...
### Question: AsnIldcpRequestPacketDataCodec extends AsnSequenceCodec<IldcpRequestPacket> { @Override public IldcpRequestPacket decode() { return IldcpRequestPacket.builder() .amount(getValueAt(0)) .expiresAt(getValueAt(1)) .build(); } AsnIldcpRequestPacketDataCodec(); @Override IldcpRequestPacket decode(); @Override v...
### Question: AesGcmStreamEncryptionService implements StreamEncryptionService { @VisibleForTesting byte[] encryptWithIv(final SharedSecret sharedSecret, final byte[] plainText, final byte[] iv) throws EncryptionException { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(plainText); Objects.requireNonNull(...
### Question: AesGcmStreamEncryptionService implements StreamEncryptionService { @Override public byte[] decrypt(final SharedSecret sharedSecret, final byte[] cipherMessage) { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(cipherMessage); if (this.encryptionMode == EncryptionMode.ENCRYPT_NON_STANDARD) { t...
### Question: StreamConnection implements Closeable { public StreamConnectionId getStreamConnectionId() { return streamConnectionId; } StreamConnection(final InterledgerAddress receiverAddress, final SharedSecret sharedSecret); StreamConnection(final StreamConnectionId streamConnectionId); UnsignedLong nextSequence();...
### Question: StreamConnection implements Closeable { public UnsignedLong nextSequence() throws StreamConnectionClosedException { final UnsignedLong nextSequence = sequence.getAndUpdate(currentSequence -> currentSequence.plus(UnsignedLong.ONE)); if (sequenceIsSafeForSingleSharedSecret(nextSequence)) { return nextSequen...
### Question: StreamConnection implements Closeable { public void transitionConnectionState() { this.connectionState.updateAndGet(streamConnectionState -> { switch (streamConnectionState) { case AVAILABLE: { return StreamConnectionState.OPEN; } case OPEN: case CLOSED: default: { return StreamConnectionState.CLOSED; } }...
### Question: StreamConnection implements Closeable { public Instant getCreationDateTime() { return creationDateTime; } StreamConnection(final InterledgerAddress receiverAddress, final SharedSecret sharedSecret); StreamConnection(final StreamConnectionId streamConnectionId); UnsignedLong nextSequence(); Instant getCre...
### Question: StreamConnection implements Closeable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } StreamConnection that = (StreamConnection) obj; return streamConnectionId.equals(that.streamConnectionId); } StreamConn...
### Question: OerLengthSerializer { public static int readLength(final InputStream inputStream) throws IOException { Objects.requireNonNull(inputStream); final int length; int initialLengthPrefixOctet = inputStream.read(); if (initialLengthPrefixOctet >= 0 && initialLengthPrefixOctet < 128) { length = initialLengthPref...
### Question: StreamConnection implements Closeable { @Override public int hashCode() { return streamConnectionId.hashCode(); } StreamConnection(final InterledgerAddress receiverAddress, final SharedSecret sharedSecret); StreamConnection(final StreamConnectionId streamConnectionId); UnsignedLong nextSequence(); Instan...
### Question: StreamConnection implements Closeable { @Override public String toString() { return new StringJoiner(", ", StreamConnection.class.getSimpleName() + "[", "]") .add("creationDateTime=" + creationDateTime) .add("streamConnectionId=" + streamConnectionId) .add("sequence=" + sequence) .add("connectionState=" +...
### Question: StreamUtils { public static InterledgerFulfillment generatedFulfillableFulfillment( final SharedSecret sharedSecret, final byte[] data ) { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(data); final SecretKey secretKey = new SecretKeySpec(sharedSecret.key(), HMAC_SHA256_ALG_NAME); final byte...
### Question: StreamUtils { public static UnsignedLong min(final UnsignedLong value1, final UnsignedLong value2) { Objects.requireNonNull(value1); Objects.requireNonNull(value2); if (is(value1).lessThan(value2)) { return value1; } else { return value2; } } static InterledgerCondition unfulfillableCondition(); static I...
### Question: StreamUtils { public static UnsignedLong max(final UnsignedLong value1, final UnsignedLong value2) { Objects.requireNonNull(value1); Objects.requireNonNull(value2); if (is(value1).greaterThan(value2)) { return value1; } else { return value2; } } static InterledgerCondition unfulfillableCondition(); stati...
### Question: StreamUtils { public static InterledgerCondition unfulfillableCondition() { return InterledgerCondition.of(Random.randBytes(32)); } static InterledgerCondition unfulfillableCondition(); static InterledgerFulfillment generatedFulfillableFulfillment( final SharedSecret sharedSecret, final byte[] data...
### Question: NoOpExchangeRateCalculator implements ExchangeRateCalculator { @Override public UnsignedLong calculateMinAmountToAccept( final UnsignedLong sendAmount, final Denomination sendAmountDenomination ) { Objects.requireNonNull(sendAmount); Objects.requireNonNull(sendAmountDenomination); return UnsignedLong.ZERO...
### Question: OerLengthSerializer { public static void writeLength(final int length, final OutputStream outputStream) throws IOException { Objects.requireNonNull(outputStream); if (length <= 0) { outputStream.write(0); } else { if (length >= 0 && length < 128) { outputStream.write(length); } else { if (length <= 127) {...
### Question: StatelessStreamReceiver implements StreamReceiver { @Override public StreamConnectionDetails setupStream(final InterledgerAddress receiverAddress) { Objects.requireNonNull(receiverAddress); return streamConnectionGenerator.generateConnectionDetails(serverSecretSupplier, receiverAddress); } StatelessStream...
### Question: AsnInterledgerAddressPrefixCodec extends AsnIA5StringBasedObjectCodec<InterledgerAddressPrefix> { @Override public InterledgerAddressPrefix decode() { return InterledgerAddressPrefix.of(getCharString()); } AsnInterledgerAddressPrefixCodec(); @Override InterledgerAddressPrefix decode(); @Override void ...
### Question: AsnOctetStringBasedObjectCodec extends AsnPrimitiveCodec<T> { public final void setBytes(byte[] bytes) { Objects.requireNonNull(bytes); validateSize(bytes); this.bytes = bytes; this.onValueChangedEvent(); } AsnOctetStringBasedObjectCodec(AsnSizeConstraint sizeConstraintInOctets); AsnOctetStringBasedObjec...
### Question: AsnSequenceOfSequenceCodec extends AsnObjectCodecBase<L> { public AsnSequenceCodec<T> getCodecAt(final int index) { Objects.requireNonNull(codecs); final AsnSequenceCodec<T> subCodec; if (codecs.size() == 0 || codecs.size() <= index) { subCodec = subCodecSupplier.get(); codecs.add(index, subCodec); } else...
### Question: AsnSequenceOfSequenceCodec extends AsnObjectCodecBase<L> { @Override public void encode(final L values) { Objects.requireNonNull(values); this.codecs = new ArrayList<>(CODECS_ARRAY_INITIAL_CAPACITY); for (T value : values) { AsnSequenceCodec<T> codec = subCodecSupplier.get(); codec.encode(value); this.cod...
### Question: AsnUintCodecUL extends AsnOctetStringBasedObjectCodec<UnsignedLong> { @Override public UnsignedLong decode() { try { return UnsignedLong.valueOf(new BigInteger(1, getBytes())); } catch (Exception e) { if (defaultValue.isPresent()) { logger.warn( "Variable Unsigned Integer was too big for VarUInt: {}. Retu...
### Question: AsnInterledgerAddressPrefixCodec extends AsnIA5StringBasedObjectCodec<InterledgerAddressPrefix> { @Override public void encode(InterledgerAddressPrefix value) { setCharString(value.getValue()); } AsnInterledgerAddressPrefixCodec(); @Override InterledgerAddressPrefix decode(); @Override void encode(Int...
### Question: AsnUintCodecUL extends AsnOctetStringBasedObjectCodec<UnsignedLong> { @Override public void encode(final UnsignedLong value) { byte[] bytes = value.bigIntegerValue().toByteArray(); if (bytes[0] == 0x00 && bytes.length > 1) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(bytes, 1, by...
### Question: AsnUintCodec extends AsnOctetStringBasedObjectCodec<BigInteger> { @Override public void encode(final BigInteger value) { if (value.compareTo(BigInteger.ZERO) < 0) { throw new IllegalArgumentException("value must be positive or zero"); } byte[] bytes = value.toByteArray(); if (bytes[0] == 0x00 && bytes.len...
### Question: AsnUintCodec extends AsnOctetStringBasedObjectCodec<BigInteger> { @Override public BigInteger decode() { return new BigInteger(1, getBytes()); } AsnUintCodec(); @Override BigInteger decode(); @Override void encode(final BigInteger value); }### Answer: @Test public void decode() { codec.setBytes(this.expe...
### Question: AsnSizeConstraint { public boolean isFixedSize() { return max != 0 && max == min; } AsnSizeConstraint(int fixedSize); AsnSizeConstraint(int min, int max); boolean isUnconstrained(); boolean isFixedSize(); int getMax(); int getMin(); @Override boolean equals(Object obj); @Override int hashCode(); static f...
### Question: AsnSizeConstraint { @Override public int hashCode() { int result = min; result = 31 * result + max; return result; } AsnSizeConstraint(int fixedSize); AsnSizeConstraint(int min, int max); boolean isUnconstrained(); boolean isFixedSize(); int getMax(); int getMin(); @Override boolean equals(Object obj); @...
### Question: PacketRejector { public InterledgerRejectPacket reject( final LinkId rejectingLinkId, final InterledgerPreparePacket preparePacket, final InterledgerErrorCode errorCode, final String errorMessage ) { Objects.requireNonNull(rejectingLinkId, "rejectingLinkId must not be null"); Objects.requireNonNull(prepar...
### Question: AsnInterledgerAddressCodec extends AsnIA5StringBasedObjectCodec<InterledgerAddress> { @Override public InterledgerAddress decode() { return Optional.ofNullable(getCharString()) .filter(charString -> !"".equals(charString)) .map(InterledgerAddress::of) .orElse(null); } AsnInterledgerAddressCodec(); @Overri...
### Question: LinkException extends RuntimeException { public LinkId getLinkId() { return linkId; } LinkException(LinkId linkId); LinkException(String message, LinkId linkId); LinkException(String message, Throwable cause, LinkId linkId); LinkException(Throwable cause, LinkId linkId); LinkException( String me...
### Question: LinkException extends RuntimeException { @Override public String toString() { String linkIdMessage = "LinkId=" + getLinkId(); String className = getClass().getName(); String message = getLocalizedMessage() == null ? linkIdMessage : getLocalizedMessage() + " " + linkIdMessage; return (className + ": " + me...
### Question: PingLoopbackLink extends AbstractLink<LinkSettings> implements Link<LinkSettings> { @Override public void registerLinkHandler(LinkHandler ilpDataHandler) throws LinkHandlerAlreadyRegisteredException { throw new RuntimeException( "PingLoopback links never have incoming data, and thus should not have a regi...
### Question: PingLoopbackLink extends AbstractLink<LinkSettings> implements Link<LinkSettings> { @Override public InterledgerResponsePacket sendPacket(final InterledgerPreparePacket preparePacket) { Objects.requireNonNull(preparePacket, "preparePacket must not be null!"); if (preparePacket.getExecutionCondition().equa...