Skip to content

Commit

Permalink
HV-571: Implementing BeanDescriptor#getConstraintsForConstructor()
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling committed Jun 17, 2012
1 parent cb44a7e commit 0508051
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Expand Up @@ -77,8 +77,7 @@ public final Set<PropertyDescriptor> getConstrainedProperties() {

@Override
public ConstructorDescriptor getConstraintsForConstructor(Class<?>... parameterTypes) {
// TODO HV-571
throw new IllegalArgumentException( "Not yet implemented" );
return constrainedConstructors.get( getElementClass().getName() + Arrays.toString( parameterTypes ) );
}

@Override
Expand Down
Expand Up @@ -33,6 +33,9 @@ public CustomerRepositoryExt(@NotNull String foo) {
public CustomerRepositoryExt(@NotNull String foo, @Min(0) int bar) {
}

public CustomerRepositoryExt(int bar) {
}

public Customer createCustomer(CharSequence firstName, String lastName) {
return null;
}
Expand Down
Expand Up @@ -215,6 +215,25 @@ public void testGetConstrainedConstructors() {
);
}

@Test
public void testGetConstraintsForConstructor() {
BeanDescriptor descriptor = getBeanDescriptor( CustomerRepositoryExt.class );
ConstructorDescriptor constructorDescriptor = descriptor.getConstraintsForConstructor(
String.class,
int.class
);

assertThat( constructorDescriptor ).isNotNull();
}

@Test
public void testGetConstraintsForUnconstrainedConstructor() {
BeanDescriptor descriptor = getBeanDescriptor( CustomerRepositoryExt.class );
ConstructorDescriptor constructorDescriptor = descriptor.getConstraintsForConstructor( int.class );

assertThat( constructorDescriptor ).isNull();
}

private Set<String> getMethodNames(Set<MethodDescriptor> descriptors) {
Set<String> methodNames = newHashSet();

Expand Down

0 comments on commit 0508051

Please sign in to comment.