Search in sources :

Example 1 with ViewAttributeBinder

use of org.robobinding.viewattribute.ViewAttributeBinder in project RoboBinding by RoboBinding.

the class ByBindingAttributeMappingsResolverTest method givenAnAttributeGroup_whenResolve_thenAResolvedGroupedViewAttributeShouldBeReturned.

@Test
public void givenAnAttributeGroup_whenResolve_thenAResolvedGroupedViewAttributeShouldBeReturned() {
    String[] attributeGroup = { "group_attribute1", "group_attribute2" };
    GroupedViewAttributeBinder viewAttributeBinder = Mockito.mock(GroupedViewAttributeBinder.class);
    ByBindingAttributeMappingsResolver byBindingAttributeMappingsResolver = newByBindingAttributeMappingsResolver(aBindingAttributeMappings().withAttributeGroup(attributeGroup, viewAttributeBinder).build());
    Collection<ViewAttributeBinder> viewAttributes = byBindingAttributeMappingsResolver.resolve(pendingAttributesForView);
    assertThat(Sets.newHashSet(viewAttributes), equalTo(Sets.<ViewAttributeBinder>newHashSet(viewAttributeBinder)));
}
Also used : GroupedViewAttributeBinder(org.robobinding.viewattribute.grouped.GroupedViewAttributeBinder) ViewAttributeBinder(org.robobinding.viewattribute.ViewAttributeBinder) PropertyViewAttributeBinder(org.robobinding.viewattribute.property.PropertyViewAttributeBinder) MultiTypePropertyViewAttributeBinder(org.robobinding.viewattribute.property.MultiTypePropertyViewAttributeBinder) GroupedViewAttributeBinder(org.robobinding.viewattribute.grouped.GroupedViewAttributeBinder) EventViewAttributeBinder(org.robobinding.viewattribute.event.EventViewAttributeBinder) Test(org.junit.Test)

Example 2 with ViewAttributeBinder

use of org.robobinding.viewattribute.ViewAttributeBinder in project RoboBinding by RoboBinding.

the class ByBindingAttributeMappingsResolverTest method givenAnEventAttribute_whenResolve_thenAResolvedEventViewAttributeShouldBeReturned.

@Test
public void givenAnEventAttribute_whenResolve_thenAResolvedEventViewAttributeShouldBeReturned() {
    EventViewAttributeBinder viewAttributeBinder = Mockito.mock(EventViewAttributeBinder.class);
    ByBindingAttributeMappingsResolver byBindingAttributeMappingsResolver = newByBindingAttributeMappingsResolver(aBindingAttributeMappings().withEventAttribute("eventAttribute", viewAttributeBinder).build());
    Collection<ViewAttributeBinder> viewAttributes = byBindingAttributeMappingsResolver.resolve(pendingAttributesForView);
    assertThat(Sets.newHashSet(viewAttributes), equalTo(Sets.<ViewAttributeBinder>newHashSet(viewAttributeBinder)));
}
Also used : ViewAttributeBinder(org.robobinding.viewattribute.ViewAttributeBinder) PropertyViewAttributeBinder(org.robobinding.viewattribute.property.PropertyViewAttributeBinder) MultiTypePropertyViewAttributeBinder(org.robobinding.viewattribute.property.MultiTypePropertyViewAttributeBinder) GroupedViewAttributeBinder(org.robobinding.viewattribute.grouped.GroupedViewAttributeBinder) EventViewAttributeBinder(org.robobinding.viewattribute.event.EventViewAttributeBinder) EventViewAttributeBinder(org.robobinding.viewattribute.event.EventViewAttributeBinder) Test(org.junit.Test)

Example 3 with ViewAttributeBinder

use of org.robobinding.viewattribute.ViewAttributeBinder in project RoboBinding by RoboBinding.

the class BindingAttributeResolver method resolve.

public ViewResolutionResult resolve(PendingAttributesForView pendingAttributesForView) {
    List<ViewAttributeBinder> resolvedViewAttributes = Lists.newArrayList();
    Iterable<ByBindingAttributeMappingsResolver> resolvers = byBindingAttributeMappingsResolverFinder.findCandidates(pendingAttributesForView.getView());
    for (ByBindingAttributeMappingsResolver resolver : resolvers) {
        Collection<ViewAttributeBinder> newResolvedViewAttributes = resolver.resolve(pendingAttributesForView);
        resolvedViewAttributes.addAll(newResolvedViewAttributes);
        if (pendingAttributesForView.isEmpty())
            break;
    }
    ViewResolutionErrors errors = pendingAttributesForView.getResolutionErrors();
    ResolvedBindingAttributesForView resolvedBindingAttributes = new ResolvedBindingAttributesForView(pendingAttributesForView.getView(), resolvedViewAttributes);
    return new ViewResolutionResult(resolvedBindingAttributes, errors);
}
Also used : ViewResolutionErrors(org.robobinding.ViewResolutionErrors) ViewAttributeBinder(org.robobinding.viewattribute.ViewAttributeBinder)

Example 4 with ViewAttributeBinder

use of org.robobinding.viewattribute.ViewAttributeBinder in project RoboBinding by RoboBinding.

the class FromClassViewAttributeFactoriesTest method shouldCreateNewInstanceFromClass.

@Test
public void shouldCreateNewInstanceFromClass() {
    ViewAttributeBinder viewAttributeBinder = FromClassViewAttributeFactories.newViewAttribute(ViewAttributeBinderImpl.class);
    assertNotNull(viewAttributeBinder);
}
Also used : ViewAttributeBinder(org.robobinding.viewattribute.ViewAttributeBinder) Test(org.junit.Test)

Example 5 with ViewAttributeBinder

use of org.robobinding.viewattribute.ViewAttributeBinder in project RoboBinding by RoboBinding.

the class ByBindingAttributeMappingsResolverTest method givenAMultiTypePropertyAttribute_whenResolve_thenAResolvedMultiTypePropertyViewAttributeShouldBeReturned.

@Test
public void givenAMultiTypePropertyAttribute_whenResolve_thenAResolvedMultiTypePropertyViewAttributeShouldBeReturned() {
    MultiTypePropertyViewAttributeBinder viewAttributeBinder = Mockito.mock(MultiTypePropertyViewAttributeBinder.class);
    ByBindingAttributeMappingsResolver byBindingAttributeMappingsResolver = newByBindingAttributeMappingsResolver(aBindingAttributeMappings().withMultiTypePropertyAttribute("multiTypePropertyAttribute", viewAttributeBinder).build());
    Collection<ViewAttributeBinder> viewAttributes = byBindingAttributeMappingsResolver.resolve(pendingAttributesForView);
    assertThat(Sets.newHashSet(viewAttributes), equalTo(Sets.<ViewAttributeBinder>newHashSet(viewAttributeBinder)));
}
Also used : MultiTypePropertyViewAttributeBinder(org.robobinding.viewattribute.property.MultiTypePropertyViewAttributeBinder) ViewAttributeBinder(org.robobinding.viewattribute.ViewAttributeBinder) PropertyViewAttributeBinder(org.robobinding.viewattribute.property.PropertyViewAttributeBinder) MultiTypePropertyViewAttributeBinder(org.robobinding.viewattribute.property.MultiTypePropertyViewAttributeBinder) GroupedViewAttributeBinder(org.robobinding.viewattribute.grouped.GroupedViewAttributeBinder) EventViewAttributeBinder(org.robobinding.viewattribute.event.EventViewAttributeBinder) Test(org.junit.Test)

Aggregations

ViewAttributeBinder (org.robobinding.viewattribute.ViewAttributeBinder)6 Test (org.junit.Test)5 EventViewAttributeBinder (org.robobinding.viewattribute.event.EventViewAttributeBinder)4 GroupedViewAttributeBinder (org.robobinding.viewattribute.grouped.GroupedViewAttributeBinder)4 MultiTypePropertyViewAttributeBinder (org.robobinding.viewattribute.property.MultiTypePropertyViewAttributeBinder)4 PropertyViewAttributeBinder (org.robobinding.viewattribute.property.PropertyViewAttributeBinder)4 ViewResolutionErrors (org.robobinding.ViewResolutionErrors)1