Skip to content

Commit

Permalink
#567 corrected test for bean-friendly modifiables
Browse files Browse the repository at this point in the history
  • Loading branch information
elucash committed Mar 6, 2017
1 parent e4e4093 commit a88c791
Showing 1 changed file with 25 additions and 4 deletions.
@@ -1,10 +1,26 @@
/*
Copyright 2017 Immutables Authors and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.immutables.fixture.modifiable; package org.immutables.fixture.modifiable;


import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import java.beans.BeanInfo;
import java.beans.Introspector; import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import org.junit.Test; import org.junit.Test;
import static org.immutables.check.Checkers.check; import static org.immutables.check.Checkers.check;


Expand All @@ -14,11 +30,16 @@ public class BeanFriendlyTest {
public void modifiableAsJavaBean() throws Exception { public void modifiableAsJavaBean() throws Exception {
ImmutableSet<String> rwProperties = ImmutableSet.of("primary", "id", "description", "names", "options"); ImmutableSet<String> rwProperties = ImmutableSet.of("primary", "id", "description", "names", "options");


BeanInfo beanInfo = Introspector.getBeanInfo(ModifiableBeanFriendly.class); FluentIterable<PropertyDescriptor> propertyDescriptors =
FluentIterable.of(
Introspector.getBeanInfo(ModifiableBeanFriendly.class)
.getPropertyDescriptors());

check(propertyDescriptors.transform(p -> p.getName()).toSet().containsAll(rwProperties));


for (java.beans.PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { for (PropertyDescriptor pd : propertyDescriptors) {
check(pd.getReadMethod()).notNull();
if (rwProperties.contains(pd.getName())) { if (rwProperties.contains(pd.getName())) {
check(pd.getReadMethod()).notNull();
check(pd.getWriteMethod()).notNull(); check(pd.getWriteMethod()).notNull();
} }
} }
Expand Down

0 comments on commit a88c791

Please sign in to comment.