StreamGroup { public StreamGroup() { } StreamGroup(); List<StreamPartition> getStreamPartitions(); void addStreamPartition(StreamPartition sp); void addStreamPartition(StreamPartition sp, boolean dedicated); void addStreamPartitions(List<StreamPartition> sps); void addStreamPartitions(List<StreamPartition> sps, boolean dedicated); @JsonIgnore boolean isDedicated(); @JsonIgnore String getStreamId(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testStreamGroup() { StreamGroup streamGroup = new StreamGroup(); Assert.assertEquals("StreamGroup dedicated=: false partitions=: [] ", streamGroup.toString()); Assert.assertEquals("SG[]", streamGroup.getStreamId()); StreamSortSpec streamSortSpec = new StreamSortSpec(); streamSortSpec.setWindowPeriod("PT10S"); StreamPartition streamPartition = new StreamPartition(); List<String> columns = new ArrayList<>(); columns.add("jobId"); streamPartition.setColumns(columns); streamPartition.setSortSpec(streamSortSpec); streamPartition.setStreamId("test"); streamPartition.setType(StreamPartition.Type.GROUPBY); streamGroup.addStreamPartition(streamPartition); Assert.assertEquals("SG[test-]", streamGroup.getStreamId()); Assert.assertEquals("StreamGroup dedicated=: false partitions=: [StreamPartition[streamId=test,type=GROUPBY,columns=[jobId],sortSpec=[StreamSortSpec[windowPeriod=PT10S,windowMargin=30000]]]] ", streamGroup.toString()); List<StreamPartition> streamPartitions = new ArrayList<>(); streamPartition.setStreamId("test1"); streamPartitions.add(streamPartition); streamGroup.addStreamPartitions(streamPartitions); Assert.assertEquals("SG[test1-test1-]", streamGroup.getStreamId()); streamPartitions = new ArrayList<>(); StreamPartition streamPartition1 = new StreamPartition(); streamPartition1.setStreamId("test2"); streamPartitions.add(streamPartition1); streamGroup.addStreamPartitions(streamPartitions); Assert.assertEquals("SG[test1-test1-test2-]", streamGroup.getStreamId()); Assert.assertEquals("StreamGroup dedicated=: false partitions=: [StreamPartition[streamId=test1,type=GROUPBY,columns=[jobId],sortSpec=[StreamSortSpec[windowPeriod=PT10S,windowMargin=30000]]], StreamPartition[streamId=test1,type=GROUPBY,columns=[jobId],sortSpec=[StreamSortSpec[windowPeriod=PT10S,windowMargin=30000]]], StreamPartition[streamId=test2,type=null,columns=[],sortSpec=[null]]] ", streamGroup.toString()); StreamGroup streamGroup1 = new StreamGroup(); streamGroup1.addStreamPartitions(streamGroup.getStreamPartitions()); Assert.assertTrue(streamGroup.equals(streamGroup1)); Assert.assertTrue(streamGroup.hashCode() == streamGroup1.hashCode()); }