@Ignore // NOCS @Test public void testRecordsWithoutStringSame() { final StringBufferFilter stringBufferFilter = new StringBufferFilter(); final List<IMonitoringRecord> inputElements = new ArrayList<>(); final List<Object> outputElements = new ArrayList<>(); final IMonitoringRecord recordIn1 = new EmptyRecord(); inputElements.add(recordIn1); StageTester.test(stringBufferFilter) .and().send(inputElements).to(stringBufferFilter.getInputPort()) .and().receive(outputElements).from(stringBufferFilter.getOutputPort()) .start(); Assert.assertEquals("Unexpected number of records", 1, outputElements.size()); final IMonitoringRecord recordOut1 = (IMonitoringRecord) outputElements.get(0); Assert.assertSame("First output record not same as first input record", recordIn1, recordOut1); // includes no String, hence "as-is" }
@Ignore // NOCS @Test public void testRecordsWithStringEqualButNeverSame() { final StringBufferFilter stringBufferFilter = new StringBufferFilter(); final List<IMonitoringRecord> inputElements = new ArrayList<>(); final List<Object> outputElements = new ArrayList<>(); long timestamp = 3268936L; final IMonitoringRecord recordIn1 = TestStringBufferFilter.createOperationExecutionRecord(timestamp); timestamp++; final IMonitoringRecord recordIn2 = TestStringBufferFilter.createOperationExecutionRecord(timestamp); inputElements.add(recordIn1); inputElements.add(recordIn2); StageTester.test(stringBufferFilter) .and().send(inputElements).to(stringBufferFilter.getInputPort()) .and().receive(outputElements).from(stringBufferFilter.getOutputPort()) .start(); Assert.assertEquals("Unexpected number of records", 2, outputElements.size()); final IMonitoringRecord recordOut1 = (IMonitoringRecord) outputElements.get(0); final IMonitoringRecord recordOut2 = (IMonitoringRecord) outputElements.get(1); Assert.assertNotSame("First output record same as first input record", recordIn1, recordOut1); // includes String, hence NOT "as-is" Assert.assertEquals("First output record doesn't equal first input record", recordIn1, recordOut1); // ... but must be equal Assert.assertNotSame("Second output record same as second input record", recordIn2, recordOut2); // includes String, hence NOT "as-is" Assert.assertEquals("Second output record doesn't equal second input record", recordIn2, recordOut2); // ... but must be equal }
@Ignore // NOCS @Test public void testObjects() { final StringBufferFilter stringBufferFilter = new StringBufferFilter(); final List<Object> inputElements = new ArrayList<>(); final List<Object> outputElements = new ArrayList<>(); final Object objectIn = new Object(); final String stringIn1 = "In-String"; final String stringIn2 = new String(stringIn1); // NOPMD (new String) Assert.assertNotSame(stringIn1, stringIn2); Assert.assertEquals(stringIn1, stringIn2); inputElements.add(objectIn); inputElements.add(stringIn1); inputElements.add(stringIn2); StageTester.test(stringBufferFilter) .and().send(inputElements).to(stringBufferFilter.getInputPort()) .and().receive(outputElements).from(stringBufferFilter.getOutputPort()) .start(); Assert.assertEquals("Unexpected number of records", 3, outputElements.size()); final Object objectOut = outputElements.get(0); Assert.assertSame("Input object not same as output object", objectIn, objectOut); final String stringOut1 = (String) outputElements.get(1); final String stringOut2 = (String) outputElements.get(2); Assert.assertSame("Input string 1 not same as output string 1", stringIn1, stringOut1); // first occurrence of a string should remain same Assert.assertEquals("Input string not equal to output string", stringIn1, stringOut1); Assert.assertNotSame("Input string 2 same as output string 2", stringIn2, stringOut2); // next occurrence should be cached Assert.assertSame("Input string 1 not same as output string 2", stringIn1, stringOut2); Assert.assertEquals("Input string not equal to output string", stringIn2, stringOut2); }
final StringBufferFilter stringBufferFilter = new StringBufferFilter(); final List<OperationExecutionRecord> inputElements = new ArrayList<>(); final List<Object> outputElements = new ArrayList<>(); .and().send(inputElements).to(stringBufferFilter.getInputPort()) .and().receive(outputElements).from(stringBufferFilter.getOutputPort()) .start();