@Test public void testNullAssociations() { when(association.getSourceRef()).thenReturn(new ArrayDelegatingEList<ItemAwareElement>() { @Override public Object[] data() { return null; } }); when(association.getAssignment()).thenReturn(new ArrayDelegatingEList<Assignment>() { @Override public Object[] data() { return null; } }); when(association.getTargetRef()).thenReturn(element); when(element.getName()).thenReturn("someName"); final Optional<InputAssignmentReader> reader = InputAssignmentReader.fromAssociation(association); assertEquals(false, reader.isPresent()); }
public static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return Optional.empty(); } if (!sourceList.isEmpty()) { return Optional.of(new InputAssignmentReader(sourceList.get(0), targetName)); } else if (!assignmentList.isEmpty()) { return Optional.of(new InputAssignmentReader(assignmentList.get(0), targetName)); } else { logger.log(Level.SEVERE, MarshallingMessage.builder().message("Cannot find SourceRef or Assignment for Target ").toString() + targetName); return Optional.empty(); } }
InputAssignmentReader { public static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return Optional.empty(); } if (!sourceList.isEmpty()) { return Optional.of(new InputAssignmentReader(sourceList.get(0), targetName)); } else if (!assignmentList.isEmpty()) { return Optional.of(new InputAssignmentReader(assignmentList.get(0), targetName)); } else { logger.log(Level.SEVERE, MarshallingMessage.builder().message("Cannot find SourceRef or Assignment for Target ").toString() + targetName); return Optional.empty(); } } }
InputAssignmentReader { public static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return Optional.empty(); } if (!sourceList.isEmpty()) { return Optional.of(new InputAssignmentReader(sourceList.get(0), targetName)); } else if (!assignmentList.isEmpty()) { return Optional.of(new InputAssignmentReader(assignmentList.get(0), targetName)); } else { logger.log(Level.SEVERE, MarshallingMessage.builder().message("Cannot find SourceRef or Assignment for Target ").toString() + targetName); return Optional.empty(); } } InputAssignmentReader(Assignment assignment, String targetName);   InputAssignmentReader(ItemAwareElement source, String targetName); }
InputAssignmentReader { public static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return Optional.empty(); } if (!sourceList.isEmpty()) { return Optional.of(new InputAssignmentReader(sourceList.get(0), targetName)); } else if (!assignmentList.isEmpty()) { return Optional.of(new InputAssignmentReader(assignmentList.get(0), targetName)); } else { logger.log(Level.SEVERE, MarshallingMessage.builder().message("Cannot find SourceRef or Assignment for Target ").toString() + targetName); return Optional.empty(); } } InputAssignmentReader(Assignment assignment, String targetName);   InputAssignmentReader(ItemAwareElement source, String targetName); static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration(); }
InputAssignmentReader { public static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return Optional.empty(); } if (!sourceList.isEmpty()) { return Optional.of(new InputAssignmentReader(sourceList.get(0), targetName)); } else if (!assignmentList.isEmpty()) { return Optional.of(new InputAssignmentReader(assignmentList.get(0), targetName)); } else { logger.log(Level.SEVERE, MarshallingMessage.builder().message("Cannot find SourceRef or Assignment for Target ").toString() + targetName); return Optional.empty(); } } InputAssignmentReader(Assignment assignment, String targetName);   InputAssignmentReader(ItemAwareElement source, String targetName); static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration();  }