SingleInputSemanticProperties implements SemanticProperties { public void addForwardedField(int sourceField, int targetField) { if(isTargetFieldPresent(targetField)) { throw new InvalidSemanticAnnotationException("Target field "+targetField+" was added twice."); } FieldSet targetFields = fieldMapping.get(sourceField); if (targetFields != null) { fieldMapping.put(sourceField, targetFields.addField(targetField)); } else { fieldMapping.put(sourceField, new FieldSet(targetField)); } } SingleInputSemanticProperties(); @Override FieldSet getForwardingTargetFields(int input, int sourceField); @Override int getForwardingSourceField(int input, int targetField); @Override FieldSet getReadFields(int input); void addForwardedField(int sourceField, int targetField); void addReadFields(FieldSet readFields); @Override String toString();  }
@Test(expected = InvalidSemanticAnnotationException.class) public void testAddForwardedFieldsTargetTwice() { SingleInputSemanticProperties sp = new SingleInputSemanticProperties(); sp.addForwardedField(0, 2); sp.addForwardedField(1, 2); }