AbstractProtocolAdapterBase extends AbstractServiceBase<T> { protected final Message addProperties( final Message msg, final QoS qos, final ResourceIdentifier target, final String publishAddress, final TenantObject tenant, final JsonObject registrationInfo, final Integer timeUntilDisconnect) { return addProperties(msg, qos, target, publishAddress, tenant, registrationInfo, timeUntilDisconnect, null); }  @Autowired @Override void setConfig(final T configuration); @Qualifier(TenantConstants.TENANT_ENDPOINT) @Autowired final void setTenantClientFactory(final TenantClientFactory factory); final TenantClientFactory getTenantClientFactory(); @Qualifier(DeviceConnectionConstants.DEVICE_CONNECTION_ENDPOINT) @Autowired final void setDeviceConnectionClientFactory(final BasicDeviceConnectionClientFactory factory); @Deprecated(forRemoval = true) final DeviceConnectionClientFactory getDeviceConnectionClientFactory(); @Qualifier(Constants.QUALIFIER_MESSAGING) @Autowired final void setDownstreamSenderFactory(final DownstreamSenderFactory factory); final DownstreamSenderFactory getDownstreamSenderFactory(); @Qualifier(RegistrationConstants.REGISTRATION_ENDPOINT) @Autowired final void setRegistrationClientFactory(final RegistrationClientFactory factory); final RegistrationClientFactory getRegistrationClientFactory(); @Qualifier(CredentialsConstants.CREDENTIALS_ENDPOINT) @Autowired final void setCredentialsClientFactory(final CredentialsClientFactory factory); final CredentialsClientFactory getCredentialsClientFactory(); @Autowired(required = false) void setConnectionEventProducer(final ConnectionEventProducer connectionEventProducer); ConnectionEventProducer getConnectionEventProducer(); @Autowired final void setCommandConsumerFactory(final ProtocolAdapterCommandConsumerFactory factory); final ProtocolAdapterCommandConsumerFactory getCommandConsumerFactory(); @Autowired final void setCommandTargetMapper(final CommandTargetMapper commandTargetMapper); @Autowired(required = false) final void setResourceLimitChecks(final ResourceLimitChecks resourceLimitChecks); final void setConnectionLimitManager(final ConnectionLimitManager connectionLimitManager); @Override void registerReadinessChecks(final HealthCheckHandler handler); @Override void registerLivenessChecks(final HealthCheckHandler handler); static ErrorCondition getErrorCondition(final Throwable t); static ConnectionAttemptOutcome getOutcome(final Throwable e);  }
@Test public void testAddPropertiesIgnoresDefaultsIfDisabled() { properties.setDefaultsEnabled(false); final Message message = ProtonHelper.message(); final ResourceIdentifier target = ResourceIdentifier.from(EventConstants.EVENT_ENDPOINT, Constants.DEFAULT_TENANT, "4711"); final JsonObject assertion = newRegistrationAssertionResult() .put(RegistrationConstants.FIELD_PAYLOAD_DEFAULTS, new JsonObject() .put(MessageHelper.SYS_HEADER_PROPERTY_TTL, 30) .put("custom-device", true)); adapter.addProperties(message, QoS.AT_LEAST_ONCE, target, null, null, assertion, null); assertThat( MessageHelper.getApplicationProperty(message.getApplicationProperties(), "custom-device", Boolean.class), is(nullValue())); assertThat(message.getTtl(), is(0L)); }
@Test public void testAddPropertiesUsesMaxTtlByDefault() { final Message message = ProtonHelper.message(); final ResourceIdentifier target = ResourceIdentifier.from(EventConstants.EVENT_ENDPOINT, Constants.DEFAULT_TENANT, "4711"); final TenantObject tenant = TenantObject.from(Constants.DEFAULT_TENANT, true) .setResourceLimits(new ResourceLimits().setMaxTtl(15L)); final JsonObject assertion = newRegistrationAssertionResult(); adapter.addProperties(message, QoS.AT_LEAST_ONCE, target, null, tenant, assertion, null); assertThat(message.getTtl(), is(15000L)); }