@Test public void testFindNodeDifference_bothNull() { NodeDifference diff = ProductPartitionNodeDiffer.diff(null, null, dimensionComparator); assertEquals(NodeDifference.NONE, diff); }
static NodeDifference diff(ProductPartitionNode originalNode, ProductPartitionNode newNode, Comparator<ProductDimension> dimensionComparator) { NodeDifference nodeDifference; if (originalNode == null && newNode == null) { nodeDifference = NodeDifference.NONE; } else if (originalNode == null) { nodeDifference = NodeDifference.NEW_NODE; } else if (newNode == null) { nodeDifference = NodeDifference.REMOVED_NODE; } else if (dimensionComparator.compare(originalNode.getDimension(), newNode.getDimension()) != 0) { throw new IllegalArgumentException( "Original node and new node are not for the same product dimension"); } else if (originalNode.isUnit() != newNode.isUnit()) { nodeDifference = NodeDifference.PARTITION_TYPE_CHANGE; } else if (originalNode.isExcludedUnit() != newNode.isExcludedUnit()) { nodeDifference = NodeDifference.EXCLUDED_UNIT_CHANGE; } else if (!originalNode.isExcludedUnit() && originalNode.isUnit() && newNode.isUnit()) { nodeDifference = NodeDifference.NONE; if (!Objects.equals(originalNode.getBid(), newNode.getBid())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals( originalNode.getTrackingUrlTemplate(), newNode.getTrackingUrlTemplate())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals(originalNode.getCustomParameters(), newNode.getCustomParameters())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } } else { nodeDifference = NodeDifference.NONE; } return nodeDifference; }
ProductPartitionNodeDiffer { static NodeDifference diff(ProductPartitionNode originalNode, ProductPartitionNode newNode, Comparator<ProductDimension> dimensionComparator) { NodeDifference nodeDifference; if (originalNode == null && newNode == null) { nodeDifference = NodeDifference.NONE; } else if (originalNode == null) { nodeDifference = NodeDifference.NEW_NODE; } else if (newNode == null) { nodeDifference = NodeDifference.REMOVED_NODE; } else if (dimensionComparator.compare(originalNode.getDimension(), newNode.getDimension()) != 0) { throw new IllegalArgumentException( "Original node and new node are not for the same product dimension"); } else if (originalNode.isUnit() != newNode.isUnit()) { nodeDifference = NodeDifference.PARTITION_TYPE_CHANGE; } else if (originalNode.isExcludedUnit() != newNode.isExcludedUnit()) { nodeDifference = NodeDifference.EXCLUDED_UNIT_CHANGE; } else if (!originalNode.isExcludedUnit() && originalNode.isUnit() && newNode.isUnit()) { nodeDifference = NodeDifference.NONE; if (!Objects.equals(originalNode.getBid(), newNode.getBid())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals( originalNode.getTrackingUrlTemplate(), newNode.getTrackingUrlTemplate())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals(originalNode.getCustomParameters(), newNode.getCustomParameters())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } } else { nodeDifference = NodeDifference.NONE; } return nodeDifference; } }
ProductPartitionNodeDiffer { static NodeDifference diff(ProductPartitionNode originalNode, ProductPartitionNode newNode, Comparator<ProductDimension> dimensionComparator) { NodeDifference nodeDifference; if (originalNode == null && newNode == null) { nodeDifference = NodeDifference.NONE; } else if (originalNode == null) { nodeDifference = NodeDifference.NEW_NODE; } else if (newNode == null) { nodeDifference = NodeDifference.REMOVED_NODE; } else if (dimensionComparator.compare(originalNode.getDimension(), newNode.getDimension()) != 0) { throw new IllegalArgumentException( "Original node and new node are not for the same product dimension"); } else if (originalNode.isUnit() != newNode.isUnit()) { nodeDifference = NodeDifference.PARTITION_TYPE_CHANGE; } else if (originalNode.isExcludedUnit() != newNode.isExcludedUnit()) { nodeDifference = NodeDifference.EXCLUDED_UNIT_CHANGE; } else if (!originalNode.isExcludedUnit() && originalNode.isUnit() && newNode.isUnit()) { nodeDifference = NodeDifference.NONE; if (!Objects.equals(originalNode.getBid(), newNode.getBid())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals( originalNode.getTrackingUrlTemplate(), newNode.getTrackingUrlTemplate())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals(originalNode.getCustomParameters(), newNode.getCustomParameters())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } } else { nodeDifference = NodeDifference.NONE; } return nodeDifference; } private  ProductPartitionNodeDiffer(); }
ProductPartitionNodeDiffer { static NodeDifference diff(ProductPartitionNode originalNode, ProductPartitionNode newNode, Comparator<ProductDimension> dimensionComparator) { NodeDifference nodeDifference; if (originalNode == null && newNode == null) { nodeDifference = NodeDifference.NONE; } else if (originalNode == null) { nodeDifference = NodeDifference.NEW_NODE; } else if (newNode == null) { nodeDifference = NodeDifference.REMOVED_NODE; } else if (dimensionComparator.compare(originalNode.getDimension(), newNode.getDimension()) != 0) { throw new IllegalArgumentException( "Original node and new node are not for the same product dimension"); } else if (originalNode.isUnit() != newNode.isUnit()) { nodeDifference = NodeDifference.PARTITION_TYPE_CHANGE; } else if (originalNode.isExcludedUnit() != newNode.isExcludedUnit()) { nodeDifference = NodeDifference.EXCLUDED_UNIT_CHANGE; } else if (!originalNode.isExcludedUnit() && originalNode.isUnit() && newNode.isUnit()) { nodeDifference = NodeDifference.NONE; if (!Objects.equals(originalNode.getBid(), newNode.getBid())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals( originalNode.getTrackingUrlTemplate(), newNode.getTrackingUrlTemplate())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals(originalNode.getCustomParameters(), newNode.getCustomParameters())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } } else { nodeDifference = NodeDifference.NONE; } return nodeDifference; } private  ProductPartitionNodeDiffer();  }
ProductPartitionNodeDiffer { static NodeDifference diff(ProductPartitionNode originalNode, ProductPartitionNode newNode, Comparator<ProductDimension> dimensionComparator) { NodeDifference nodeDifference; if (originalNode == null && newNode == null) { nodeDifference = NodeDifference.NONE; } else if (originalNode == null) { nodeDifference = NodeDifference.NEW_NODE; } else if (newNode == null) { nodeDifference = NodeDifference.REMOVED_NODE; } else if (dimensionComparator.compare(originalNode.getDimension(), newNode.getDimension()) != 0) { throw new IllegalArgumentException( "Original node and new node are not for the same product dimension"); } else if (originalNode.isUnit() != newNode.isUnit()) { nodeDifference = NodeDifference.PARTITION_TYPE_CHANGE; } else if (originalNode.isExcludedUnit() != newNode.isExcludedUnit()) { nodeDifference = NodeDifference.EXCLUDED_UNIT_CHANGE; } else if (!originalNode.isExcludedUnit() && originalNode.isUnit() && newNode.isUnit()) { nodeDifference = NodeDifference.NONE; if (!Objects.equals(originalNode.getBid(), newNode.getBid())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals( originalNode.getTrackingUrlTemplate(), newNode.getTrackingUrlTemplate())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } if (!Objects.equals(originalNode.getCustomParameters(), newNode.getCustomParameters())) { nodeDifference = NodeDifference.BIDDABLE_UNIT_CHANGE; } } else { nodeDifference = NodeDifference.NONE; } return nodeDifference; } private  ProductPartitionNodeDiffer();   }