|
20 | 20 | import static org.hamcrest.Matchers.isA; |
21 | 21 | import static org.junit.Assert.assertEquals; |
22 | 22 | import static org.junit.Assert.assertNotNull; |
| 23 | +import static org.junit.Assert.assertTrue; |
23 | 24 |
|
24 | 25 |
|
25 | 26 | public class BeatsParserTest { |
@@ -135,6 +136,45 @@ public void testShouldNotCrashOnGarbageData() { |
135 | 136 | sendPayloadToParser(randomBufferData); |
136 | 137 | } |
137 | 138 |
|
| 139 | + @Test |
| 140 | + public void testV1EmptyWindowEmitsEmptyBatch() { |
| 141 | + Batch decodedBatch = decodeBatch(new V1Batch()); |
| 142 | + |
| 143 | + assertNotNull(decodedBatch); |
| 144 | + assertTrue(decodedBatch.isEmpty()); |
| 145 | + assertEquals(0, decodedBatch.getBatchSize()); |
| 146 | + assertEquals(0, decodedBatch.size()); |
| 147 | + } |
| 148 | + @Test |
| 149 | + public void testV2EmptyWindowEmitsEmptyBatch() { |
| 150 | + Batch decodedBatch = decodeBatch(new V2Batch()); |
| 151 | + |
| 152 | + assertNotNull(decodedBatch); |
| 153 | + assertTrue(decodedBatch.isEmpty()); |
| 154 | + assertEquals(0, decodedBatch.getBatchSize()); |
| 155 | + assertEquals(0, decodedBatch.size()); |
| 156 | + } |
| 157 | + |
| 158 | + |
| 159 | + @Test |
| 160 | + public void testV1CompressedFrameEmptyWindowEmitsEmptyBatch() { |
| 161 | + Batch decodedBatch = decodeCompressedBatch(new V1Batch()); |
| 162 | + |
| 163 | + assertNotNull(decodedBatch); |
| 164 | + assertTrue(decodedBatch.isEmpty()); |
| 165 | + assertEquals(0, decodedBatch.getBatchSize()); |
| 166 | + assertEquals(0, decodedBatch.size()); |
| 167 | + } |
| 168 | + @Test |
| 169 | + public void testV2CompressedFrameEmptyWindowEmitsEmptyBatch() { |
| 170 | + Batch decodedBatch = decodeCompressedBatch(new V2Batch()); |
| 171 | + |
| 172 | + assertNotNull(decodedBatch); |
| 173 | + assertTrue(decodedBatch.isEmpty()); |
| 174 | + assertEquals(0, decodedBatch.getBatchSize()); |
| 175 | + assertEquals(0, decodedBatch.size()); |
| 176 | + } |
| 177 | + |
138 | 178 |
|
139 | 179 | @Test |
140 | 180 | public void testNegativeJsonPayloadShouldRaiseAnException() throws JsonProcessingException { |
|
0 commit comments