Source:
<code>public void testAttributeValuesSerializableCheck() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { LogicalPlan dag = new LogicalPlan(); <START> Attribute<Object> attr = new Attribute<Object>(new TestAttributeValue(), new Object2String()); <END> Field nameField = Attribute.class.getDeclaredField("name"); nameField.setAccessible(true); nameField.set(attr, "Test_Attribute"); nameField.setAccessible(false); assertNotNull(attr); dag.setAttribute(attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting not serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in com.datatorrent.api.DAG are not serializable", e.getMessage()); } dag = new LogicalPlan(); TestGeneratorInputOperator operator = dag.addOperator("TestOperator", TestGeneratorInputOperator.class); dag.setAttribute(operator, attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting not serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in TestOperator are not serializable", e.getMessage()); } dag = new LogicalPlan(); operator = dag.addOperator("TestOperator", TestGeneratorInputOperator.class); dag.setOutputPortAttribute(operator.outport, attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting not serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in TestOperator.outport are not serializable", e.getMessage()); } dag = new LogicalPlan(); GenericTestOperator operator1 = dag.addOperator("TestOperator", GenericTestOperator.class); dag.setInputPortAttribute(operator1.inport1, attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting non serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in TestOperator.inport1 are not serializable", e.getMessage()); } }</code><technical_language>new Attribute<Object> new Attribute<></technical_language>

Target:
public void testAttributeValuesSerializableCheck() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { LogicalPlan dag = new LogicalPlan(); Attribute<Object> attr = new Attribute<>(new TestAttributeValue(), new Object2String()); Field nameField = Attribute.class.getDeclaredField("name"); nameField.setAccessible(true); nameField.set(attr, "Test_Attribute"); nameField.setAccessible(false); dag.setAttribute(attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting not serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in com.datatorrent.api.DAG are not serializable", e.getMessage()); } dag = new LogicalPlan(); TestGeneratorInputOperator operator = dag.addOperator("TestOperator", TestGeneratorInputOperator.class); dag.setAttribute(operator, attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting not serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in TestOperator are not serializable", e.getMessage()); } dag = new LogicalPlan(); operator = dag.addOperator("TestOperator", TestGeneratorInputOperator.class); dag.setOutputPortAttribute(operator.outport, attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting not serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in TestOperator.outport are not serializable", e.getMessage()); } dag = new LogicalPlan(); GenericTestOperator operator1 = dag.addOperator("TestOperator", GenericTestOperator.class); dag.setInputPortAttribute(operator1.inport1, attr, new TestAttributeValue()); try { dag.validate(); Assert.fail("Setting non serializable attribute should throw exception"); } catch (ValidationException e) { assertEquals("Validation Exception should match ", "Attribute value(s) for Test_Attribute in TestOperator.inport1 are not serializable", e.getMessage()); } }