@Test @SuppressWarnings("unchecked") public void taskCompletedSerializeWithWarnsWithObjsTest() throws MessageSerializerException { TaskCompleted operation = new TaskCompletedBuilder(5, 6) .addWarning("warning 1") .addWarning("warning 1") .addWarning("warning 2") .addWarning("warning 3") .addNewObjectId(1L) .addNewObjectId(6L) .addNewObjectId(9L) .addNewObjectId(30L) .build(); Message message = serializer.serialize(operation); Assert.assertNotNull(message); Assert.assertEquals(message.getType(), "TaskCompleted"); TaskCompleted deserialized = (TaskCompleted) serializer.deserialize(message); Assert.assertNotNull(deserialized); Assert.assertEquals(deserialized.getJobId(), 5); Assert.assertEquals(deserialized.getTaskId(), 6); Assert.assertNotNull(deserialized.getWarnings()); Assert.assertEquals(deserialized.getWarnings().size(), 4); Assert.assertEquals(deserialized.getWarnings().get(0), "warning 1"); Assert.assertEquals(deserialized.getWarnings().get(1), "warning 1"); Assert.assertEquals(deserialized.getWarnings().get(2), "warning 2"); Assert.assertEquals(deserialized.getWarnings().get(3), "warning 3"); Assert.assertEquals(deserialized.getObjects().size(), 4); Assert.assertTrue(deserialized.getObjects().contains(1L)); Assert.assertTrue(deserialized.getObjects().contains(6L)); Assert.assertTrue(deserialized.getObjects().contains(9L)); Assert.assertTrue(deserialized.getObjects().contains(30L)); }
@Test @SuppressWarnings("unchecked") public void taskCompletedSerializeNoWarnsNoObjsTest() throws MessageSerializerException { TaskCompleted operation = new TaskCompletedBuilder(5, 6).build(); Message message = serializer.serialize(operation); Assert.assertNotNull(message); Assert.assertEquals(message.getType(), "TaskCompleted"); TaskCompleted deserialized = (TaskCompleted) serializer.deserialize(message); Assert.assertNotNull(deserialized); Assert.assertEquals(deserialized.getJobId(), 5); Assert.assertEquals(deserialized.getTaskId(), 6); Assert.assertNotNull(deserialized.getWarnings()); Assert.assertEquals(deserialized.getWarnings().size(), 0); Assert.assertNotNull(deserialized.getObjects()); Assert.assertEquals(deserialized.getObjects().size(), 0); }