AbstractProtocolAdapterBase extends AbstractServiceBase<T> { protected boolean isPayloadOfIndicatedType(final Buffer payload, final String contentType) { if (payload == null || payload.length() == 0) { return EventConstants.CONTENT_TYPE_EMPTY_NOTIFICATION.equals(contentType); } else { return !EventConstants.CONTENT_TYPE_EMPTY_NOTIFICATION.equals(contentType); } }  @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 testEmptyNotificationWithoutPayload() { adapter = newProtocolAdapter(properties, null); final Buffer payload = null; final String contentType = EventConstants.CONTENT_TYPE_EMPTY_NOTIFICATION; assertTrue(adapter.isPayloadOfIndicatedType(payload, contentType)); }
@Test public void testEmptyNotificationWithPayload() { adapter = newProtocolAdapter(properties, null); final Buffer payload = Buffer.buffer("test"); final String contentType = EventConstants.CONTENT_TYPE_EMPTY_NOTIFICATION; assertFalse(adapter.isPayloadOfIndicatedType(payload, contentType)); }
@Test public void testNonEmptyGeneralMessage() { adapter = newProtocolAdapter(properties, null); final Buffer payload = Buffer.buffer("test"); final String arbitraryContentType = "bum/lux"; assertTrue(adapter.isPayloadOfIndicatedType(payload, arbitraryContentType)); }
@Test public void testNonEmptyMessageWithoutContentType() { adapter = newProtocolAdapter(properties, null); final Buffer payload = Buffer.buffer("test"); assertTrue(adapter.isPayloadOfIndicatedType(payload, null)); }
@Test public void testEmptyGeneralMessage() { adapter = newProtocolAdapter(properties, null); final Buffer payload = null; final String arbitraryContentType = "bum/lux"; assertFalse(adapter.isPayloadOfIndicatedType(payload, arbitraryContentType)); }