Package de.danielbechler.diff.access

Examples of de.danielbechler.diff.access.PropertyAwareAccessor


  @Test
  public void delegate_comparison_of_properties_when_comparing_via_introspector()
  {
    given_root_node_is_introspectable();
    final PropertyAwareAccessor propertyAccessor = given_introspector_returns_PropertyAccessor("foo");
    final DiffNode propertyNode = given_DifferDispatcher_returns_Node_for_PropertyAccessor(propertyAccessor);
    given_Node_is_returnable(propertyNode);

    final DiffNode node = beanDiffer.compare(DiffNode.ROOT, instances);
View Full Code Here


  }

  private PropertyAwareAccessor given_introspector_returns_PropertyAccessor(final String propertyName)
  {
    final BeanPropertyElementSelector propertyElement = new BeanPropertyElementSelector(propertyName);
    final PropertyAwareAccessor propertyAccessor = mock(PropertyAwareAccessor.class);
    when(propertyAccessor.getElementSelector()).thenReturn(propertyElement);
    final TypeInfo typeInfo = new TypeInfo(Class.class);
    typeInfo.addPropertyAccessor(propertyAccessor);
    when(typeInfoResolver.typeInfoForNode(any(DiffNode.class))).thenReturn(typeInfo);
    return propertyAccessor;
  }
View Full Code Here

  @Test
  public void do_not_add_property_nodes_to_bean_node_if_they_are_not_returnable()
  {
    given_root_node_is_introspectable();
    final PropertyAwareAccessor propertyAccessor = given_introspector_returns_PropertyAccessor("foo");
    final DiffNode propertyNode = given_DifferDispatcher_returns_Node_for_PropertyAccessor(propertyAccessor);
    given_Node_is_not_returnable(propertyNode);

    final DiffNode node = beanDiffer.compare(DiffNode.ROOT, instances);
View Full Code Here

  @Test
  public void getPropertyName_returns_name_from_PropertyAwareAccessor()
  {
    final String expectedPropertyName = "foo";
    final PropertyAwareAccessor accessor = Mockito.mock(PropertyAwareAccessor.class);
    Mockito.when(accessor.getPropertyName()).thenReturn(expectedPropertyName);

    final DiffNode diffNode = new DiffNode(accessor, Object.class);
    final String actualPropertyName = diffNode.getPropertyName();

    assertThat(actualPropertyName).isEqualTo(expectedPropertyName);
View Full Code Here

  @Test
  public void getPropertyName_returns_name_from_parentNode()
  {
    final String expectedPropertyName = "foo";

    final PropertyAwareAccessor propertyAwareAccessor = Mockito.mock(PropertyAwareAccessor.class);
    Mockito.when(propertyAwareAccessor.getPropertyName()).thenReturn(expectedPropertyName);

    final DiffNode parentNodeWithPropertyAwareAccessor = new DiffNode(propertyAwareAccessor, Object.class);
    final DiffNode node = new DiffNode(parentNodeWithPropertyAwareAccessor, Mockito.mock(Accessor.class), Object.class);

    assertThat(node.getPropertyName()).isEqualTo(expectedPropertyName);
View Full Code Here

  }

  @Test
  public void isPropertyAware_returns_true()
  {
    final PropertyAwareAccessor propertyAwareAccessor = Mockito.mock(PropertyAwareAccessor.class);
    final DiffNode node = new DiffNode(propertyAwareAccessor, Object.class);

    assertThat(node.isPropertyAware()).isTrue();
  }
View Full Code Here

        continue;
      }
      final String propertyName = descriptor.getName();
      final Method readMethod = descriptor.getReadMethod();
      final Method writeMethod = descriptor.getWriteMethod();
      final PropertyAwareAccessor accessor = new PropertyAccessor(propertyName, readMethod, writeMethod);
      typeInfo.addPropertyAccessor(accessor);
    }
    return typeInfo;
  }
View Full Code Here

    }

    final Instances accessedInstances;
    if (accessor instanceof PropertyAwareAccessor)
    {
      final PropertyAwareAccessor propertyAwareAccessor = (PropertyAwareAccessor) accessor;
      try
      {
        accessedInstances = parentInstances.access(accessor);
      }
      catch (final PropertyReadException e)
      {
        node.setState(DiffNode.State.INACCESSIBLE);
        final Class<?> parentType = parentInstances.getType();
        final String propertyName = propertyAwareAccessor.getPropertyName();
        final PropertyAccessExceptionHandler exceptionHandler = propertyAccessExceptionHandlerResolver
            .resolvePropertyAccessExceptionHandler(parentType, propertyName);
        if (exceptionHandler != null)
        {
          exceptionHandler.onPropertyReadException(e, node);
View Full Code Here

TOP

Related Classes of de.danielbechler.diff.access.PropertyAwareAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.