@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDataType() == null) ? 0 : getDataType().hashCode()); hashCode = prime * hashCode + ((getStringValue() == null) ? 0 : getStringValue().hashCode()); hashCode = prime * hashCode + ((getBinaryValue() == null) ? 0 : getBinaryValue().hashCode()); return hashCode; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDataType() != null) sb.append("DataType: ").append(getDataType()).append(","); if (getStringValue() != null) sb.append("StringValue: ").append(getStringValue()).append(","); if (getBinaryValue() != null) sb.append("BinaryValue: ").append(getBinaryValue()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof MessageAttributeValue == false) return false; MessageAttributeValue other = (MessageAttributeValue) obj; if (other.getDataType() == null ^ this.getDataType() == null) return false; if (other.getDataType() != null && other.getDataType().equals(this.getDataType()) == false) return false; if (other.getStringValue() == null ^ this.getStringValue() == null) return false; if (other.getStringValue() != null && other.getStringValue().equals(this.getStringValue()) == false) return false; if (other.getBinaryValue() == null ^ this.getBinaryValue() == null) return false; if (other.getBinaryValue() != null && other.getBinaryValue().equals(this.getBinaryValue()) == false) return false; return true; }
if (entry.getValue().getStringValue() != null) { request.addParameter("MessageAttributes.entry." + messageAttributesListIndex + ".Value.StringValue", StringUtils.fromString(entry.getValue().getStringValue()));
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDataType() == null) ? 0 : getDataType().hashCode()); hashCode = prime * hashCode + ((getStringValue() == null) ? 0 : getStringValue().hashCode()); hashCode = prime * hashCode + ((getBinaryValue() == null) ? 0 : getBinaryValue().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDataType() != null) sb.append("DataType: " + getDataType() + ","); if (getStringValue() != null) sb.append("StringValue: " + getStringValue() + ","); if (getBinaryValue() != null) sb.append("BinaryValue: " + getBinaryValue()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof MessageAttributeValue == false) return false; MessageAttributeValue other = (MessageAttributeValue) obj; if (other.getDataType() == null ^ this.getDataType() == null) return false; if (other.getDataType() != null && other.getDataType().equals(this.getDataType()) == false) return false; if (other.getStringValue() == null ^ this.getStringValue() == null) return false; if (other.getStringValue() != null && other.getStringValue().equals(this.getStringValue()) == false) return false; if (other.getBinaryValue() == null ^ this.getBinaryValue() == null) return false; if (other.getBinaryValue() != null && other.getBinaryValue().equals(this.getBinaryValue()) == false) return false; return true; } }
public void marshall(MessageAttributeValue _messageAttributeValue, Request<?> request, String _prefix) { String prefix; if (_messageAttributeValue.getDataType() != null) { prefix = _prefix + "DataType"; String dataType = _messageAttributeValue.getDataType(); request.addParameter(prefix, StringUtils.fromString(dataType)); } if (_messageAttributeValue.getStringValue() != null) { prefix = _prefix + "StringValue"; String stringValue = _messageAttributeValue.getStringValue(); request.addParameter(prefix, StringUtils.fromString(stringValue)); } if (_messageAttributeValue.getBinaryValue() != null) { prefix = _prefix + "BinaryValue"; java.nio.ByteBuffer binaryValue = _messageAttributeValue.getBinaryValue(); request.addParameter(prefix, StringUtils.fromByteBuffer(binaryValue)); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDataType() == null) ? 0 : getDataType().hashCode()); hashCode = prime * hashCode + ((getStringValue() == null) ? 0 : getStringValue().hashCode()); hashCode = prime * hashCode + ((getBinaryValue() == null) ? 0 : getBinaryValue().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDataType() != null) sb.append("DataType: " + getDataType() + ","); if (getStringValue() != null) sb.append("StringValue: " + getStringValue() + ","); if (getBinaryValue() != null) sb.append("BinaryValue: " + getBinaryValue()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof MessageAttributeValue == false) return false; MessageAttributeValue other = (MessageAttributeValue) obj; if (other.getDataType() == null ^ this.getDataType() == null) return false; if (other.getDataType() != null && other.getDataType().equals(this.getDataType()) == false) return false; if (other.getStringValue() == null ^ this.getStringValue() == null) return false; if (other.getStringValue() != null && other.getStringValue().equals(this.getStringValue()) == false) return false; if (other.getBinaryValue() == null ^ this.getBinaryValue() == null) return false; if (other.getBinaryValue() != null && other.getBinaryValue().equals(this.getBinaryValue()) == false) return false; return true; } }
public void marshall(MessageAttributeValue _messageAttributeValue, Request<?> request, String _prefix) { String prefix; if (_messageAttributeValue.getDataType() != null) { prefix = _prefix + "DataType"; String dataType = _messageAttributeValue.getDataType(); request.addParameter(prefix, StringUtils.fromString(dataType)); } if (_messageAttributeValue.getStringValue() != null) { prefix = _prefix + "StringValue"; String stringValue = _messageAttributeValue.getStringValue(); request.addParameter(prefix, StringUtils.fromString(stringValue)); } if (_messageAttributeValue.getBinaryValue() != null) { prefix = _prefix + "BinaryValue"; java.nio.ByteBuffer binaryValue = _messageAttributeValue.getBinaryValue(); request.addParameter(prefix, StringUtils.fromByteBuffer(binaryValue)); } }
@Test @SuppressWarnings("unchecked") public void testSnsMessageHandler() { SnsBodyBuilder payload = SnsBodyBuilder.withDefault("foo") .forProtocols("{\"foo\" : \"bar\"}", "sms"); Message<?> message = MessageBuilder.withPayload(payload) .setHeader("topic", "topic") .setHeader("subject", "subject") .setHeader("foo", "bar") .build(); this.sendToSnsChannel.send(message); Message<?> reply = this.resultChannel.receive(10000); assertThat(reply).isNotNull(); ArgumentCaptor<PublishRequest> captor = ArgumentCaptor.forClass(PublishRequest.class); verify(this.amazonSNS).publishAsync(captor.capture(), any(AsyncHandler.class)); PublishRequest publishRequest = captor.getValue(); assertThat(publishRequest.getMessageStructure()).isEqualTo("json"); assertThat(publishRequest.getTopicArn()).isEqualTo("topic"); assertThat(publishRequest.getSubject()).isEqualTo("subject"); assertThat(publishRequest.getMessage()) .isEqualTo("{\"default\":\"foo\",\"sms\":\"{\\\"foo\\\" : \\\"bar\\\"}\"}"); Map<String, MessageAttributeValue> messageAttributes = publishRequest.getMessageAttributes(); assertThat(messageAttributes).doesNotContainKey(MessageHeaders.ID); assertThat(messageAttributes).doesNotContainKey(MessageHeaders.TIMESTAMP); assertThat(messageAttributes).containsKey("foo"); assertThat(messageAttributes.get("foo").getStringValue()).isEqualTo("bar"); assertThat(reply.getHeaders().get(AwsHeaders.MESSAGE_ID)).isEqualTo("111"); assertThat(reply.getHeaders().get(AwsHeaders.TOPIC)).isEqualTo("topic"); assertThat(reply.getPayload()).isSameAs(payload); }