@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getQueueUrls() == null) ? 0 : getQueueUrls().hashCode()); return hashCode; }
public ListQueuesResult unmarshall(StaxUnmarshallerContext context) throws Exception { ListQueuesResult listQueuesResult = new ListQueuesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return listQueuesResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("QueueUrl", targetDepth)) { listQueuesResult.withQueueUrls(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return listQueuesResult; } } } }
/** * <p> * A list of queue URLs, up to 1,000 entries. * </p> * * @param queueUrls * A list of queue URLs, up to 1,000 entries. * @return Returns a reference to this object so that method calls can be chained together. */ public ListQueuesResult withQueueUrls(java.util.Collection<String> queueUrls) { setQueueUrls(queueUrls); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListQueuesResult == false) return false; ListQueuesResult other = (ListQueuesResult) obj; if (other.getQueueUrls() == null ^ this.getQueueUrls() == null) return false; if (other.getQueueUrls() != null && other.getQueueUrls().equals(this.getQueueUrls()) == false) return false; return true; }
@Test public void testGetQueueWithCustomConfiguration() { when(configuration.getIntProperty(eq("workflow.event.queues.sqs.batchSize"), anyInt())).thenReturn(10); when(configuration.getIntProperty(eq("workflow.event.queues.sqs.pollTimeInMS"), anyInt())).thenReturn(50); when(configuration.getIntProperty(eq("workflow.event.queues.sqs.visibilityTimeoutInSeconds"), anyInt())).thenReturn(30); ListQueuesResult listQueuesResult = new ListQueuesResult().withQueueUrls("test_queue_1"); when(amazonSQSClient.listQueues(any(ListQueuesRequest.class))).thenReturn(listQueuesResult); SQSEventQueueProvider sqsEventQueueProvider = new SQSEventQueueProvider(amazonSQSClient, configuration); SQSObservableQueue sqsObservableQueue = (SQSObservableQueue) sqsEventQueueProvider.getQueue("test_queue_1"); assertNotNull(sqsObservableQueue); assertEquals(10, sqsObservableQueue.getBatchSize()); assertEquals(50, sqsObservableQueue.getPollTimeInMS()); assertEquals(30, sqsObservableQueue.getVisibilityTimeoutInSeconds()); }
/** * <p> * A list of queue URLs, up to 1,000 entries. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setQueueUrls(java.util.Collection)} or {@link #withQueueUrls(java.util.Collection)} if you want to * override the existing values. * </p> * * @param queueUrls * A list of queue URLs, up to 1,000 entries. * @return Returns a reference to this object so that method calls can be chained together. */ public ListQueuesResult withQueueUrls(String... queueUrls) { if (this.queueUrls == null) { setQueueUrls(new com.amazonaws.internal.SdkInternalList<String>(queueUrls.length)); } for (String ele : queueUrls) { this.queueUrls.add(ele); } return this; }
/** * 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 (getQueueUrls() != null) sb.append("QueueUrls: ").append(getQueueUrls()); sb.append("}"); return sb.toString(); }
@Test public void testGetQueueWithDefaultConfiguration() { when(configuration.getIntProperty(anyString(), anyInt())).thenAnswer(invocation -> invocation.getArguments()[1]); ListQueuesResult listQueuesResult = new ListQueuesResult().withQueueUrls("test_queue_1"); when(amazonSQSClient.listQueues(any(ListQueuesRequest.class))).thenReturn(listQueuesResult); SQSEventQueueProvider sqsEventQueueProvider = new SQSEventQueueProvider(amazonSQSClient, configuration); SQSObservableQueue sqsObservableQueue = (SQSObservableQueue) sqsEventQueueProvider.getQueue("test_queue_1"); assertNotNull(sqsObservableQueue); assertEquals(1, sqsObservableQueue.getBatchSize()); assertEquals(100, sqsObservableQueue.getPollTimeInMS()); assertEquals(60, sqsObservableQueue.getVisibilityTimeoutInSeconds()); }
/** * <p> * A list of queue URLs, up to 1000 entries. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param queueUrls <p> * A list of queue URLs, up to 1000 entries. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public ListQueuesResult withQueueUrls(java.util.Collection<String> queueUrls) { setQueueUrls(queueUrls); return this; }
private List<String> listQueues(String queueName) { ListQueuesRequest listQueuesRequest = new ListQueuesRequest().withQueueNamePrefix(queueName); ListQueuesResult resultList = client.listQueues(listQueuesRequest); return resultList.getQueueUrls().stream() .filter(queueUrl -> queueUrl.contains(queueName)) .collect(Collectors.toList()); }
@Test public void testException() { com.amazonaws.services.sqs.model.Message message = new com.amazonaws.services.sqs.model.Message().withMessageId("test") .withBody("") .withReceiptHandle("receiptHandle"); Answer<?> answer = (Answer<ReceiveMessageResult>) invocation -> new ReceiveMessageResult(); AmazonSQSClient client = mock(AmazonSQSClient.class); when(client.listQueues(any(ListQueuesRequest.class))).thenReturn(new ListQueuesResult().withQueueUrls("junit_queue_url")); when(client.receiveMessage(any(ReceiveMessageRequest.class))).thenThrow(new RuntimeException("Error in SQS communication")) .thenReturn(new ReceiveMessageResult().withMessages(message)) .thenAnswer(answer); SQSObservableQueue queue = new SQSObservableQueue.Builder() .withQueueName("junit") .withClient(client).build(); List<Message> found = new LinkedList<>(); Observable<Message> observable = queue.observe(); assertNotNull(observable); observable.subscribe(found::add); Uninterruptibles.sleepUninterruptibly(1000, TimeUnit.MILLISECONDS); assertEquals(1, found.size()); } }
/** * <p> * A list of queue URLs, up to 1,000 entries. * </p> * * @param queueUrls * A list of queue URLs, up to 1,000 entries. * @return Returns a reference to this object so that method calls can be chained together. */ public ListQueuesResult withQueueUrls(java.util.Collection<String> queueUrls) { setQueueUrls(queueUrls); return this; }
for (String url : lq_result.getQueueUrls()) { System.out.println(url); lq_result = sqs.listQueues(new ListQueuesRequest(name_prefix)); System.out.println("Queue URLs with prefix: " + name_prefix); for (String url : lq_result.getQueueUrls()) { System.out.println(url);
public ListQueuesResult unmarshall(StaxUnmarshallerContext context) throws Exception { ListQueuesResult listQueuesResult = new ListQueuesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("QueueUrl", targetDepth)) { listQueuesResult.withQueueUrls(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return listQueuesResult; }
/** * <p> * A list of queue URLs, up to 1000 entries. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param queueUrls <p> * A list of queue URLs, up to 1000 entries. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public ListQueuesResult withQueueUrls(java.util.Collection<String> queueUrls) { setQueueUrls(queueUrls); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getQueueUrls() == null) ? 0 : getQueueUrls().hashCode()); return hashCode; }
public ListQueuesResult unmarshall(StaxUnmarshallerContext context) throws Exception { ListQueuesResult listQueuesResult = new ListQueuesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return listQueuesResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("QueueUrl", targetDepth)) { listQueuesResult.withQueueUrls(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return listQueuesResult; } } } }
/** * <p> * A list of queue URLs, up to 1,000 entries. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setQueueUrls(java.util.Collection)} or {@link #withQueueUrls(java.util.Collection)} if you want to * override the existing values. * </p> * * @param queueUrls * A list of queue URLs, up to 1,000 entries. * @return Returns a reference to this object so that method calls can be chained together. */ public ListQueuesResult withQueueUrls(String... queueUrls) { if (this.queueUrls == null) { setQueueUrls(new com.amazonaws.internal.SdkInternalList<String>(queueUrls.length)); } for (String ele : queueUrls) { this.queueUrls.add(ele); } return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListQueuesResult == false) return false; ListQueuesResult other = (ListQueuesResult) obj; if (other.getQueueUrls() == null ^ this.getQueueUrls() == null) return false; if (other.getQueueUrls() != null && other.getQueueUrls().equals(this.getQueueUrls()) == false) return false; return true; } }
public ListQueuesResult unmarshall(StaxUnmarshallerContext context) throws Exception { ListQueuesResult listQueuesResult = new ListQueuesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("QueueUrl", targetDepth)) { listQueuesResult.withQueueUrls(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return listQueuesResult; }