public DescribeStreamResult unmarshall(JsonUnmarshallerContext context) throws Exception { DescribeStreamResult describeStreamResult = new DescribeStreamResult(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) { return describeStreamResult; } while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("StreamDescription", targetDepth)) { context.nextToken(); describeStreamResult.setStreamDescription(StreamDescriptionJsonUnmarshaller.getInstance().unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return describeStreamResult; }
public DescribeStreamResult unmarshall(JsonUnmarshallerContext context) throws Exception { DescribeStreamResult describeStreamResult = new DescribeStreamResult(); AwsJsonReader reader = context.getReader(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("StreamDescription")) { describeStreamResult.setStreamDescription(StreamDescriptionJsonUnmarshaller .getInstance() .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return describeStreamResult; }
@Override public DescribeStreamResult describeStream(String streamName, String exclusiveStartShardId) { int nextShardId = 0; if (exclusiveStartShardId != null) { nextShardId = parseInt(exclusiveStartShardId) + 1; } boolean hasMoreShards = nextShardId + 1 < shardedData.size(); List<Shard> shards = new ArrayList<>(); if (nextShardId < shardedData.size()) { shards.add(new Shard().withShardId(Integer.toString(nextShardId))); } HttpResponse response = new HttpResponse(null, null); response.setStatusCode(200); DescribeStreamResult result = new DescribeStreamResult(); result.setSdkHttpMetadata(SdkHttpMetadata.from(response)); result.withStreamDescription( new StreamDescription() .withHasMoreShards(hasMoreShards) .withShards(shards) .withStreamName(streamName)); return result; }
public DescribeStreamResult unmarshall(JsonUnmarshallerContext context) throws Exception { DescribeStreamResult describeStreamResult = new DescribeStreamResult(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) { return describeStreamResult; } while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("StreamDescription", targetDepth)) { context.nextToken(); describeStreamResult.setStreamDescription(StreamDescriptionJsonUnmarshaller.getInstance().unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return describeStreamResult; }
@Test public void shouldListAllShards() throws Exception { Shard shard1 = new Shard().withShardId(SHARD_1); Shard shard2 = new Shard().withShardId(SHARD_2); Shard shard3 = new Shard().withShardId(SHARD_3); given(kinesis.describeStream(STREAM, null)) .willReturn( new DescribeStreamResult() .withStreamDescription( new StreamDescription().withShards(shard1, shard2).withHasMoreShards(true))); given(kinesis.describeStream(STREAM, SHARD_2)) .willReturn( new DescribeStreamResult() .withStreamDescription( new StreamDescription().withShards(shard3).withHasMoreShards(false))); List<Shard> shards = underTest.listShards(STREAM); assertThat(shards).containsOnly(shard1, shard2, shard3); }
new DescribeStreamResult() .withStreamDescription(new StreamDescription() .withStreamName(STREAM_FOR_RESHARDING)
.willReturn(new DescribeStreamResult() .withStreamDescription(new StreamDescription() .withStreamName(STREAM1) .withStreamStatus(StreamStatus.UPDATING)), new DescribeStreamResult() .withStreamDescription(new StreamDescription() .withStreamName(STREAM1)