package org.rocket.network.acara;

import org.junit.Test;
import org.rocket.network.PropValidator;
import org.rocket.network.props.PropPresence;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.AnnotatedElement;
import java.util.List;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

public class ValidationsTest {
    @Retention(RetentionPolicy.RUNTIME)
    @PropPresence(String.class)
    @interface FooBar {}

    @SuppressWarnings("UnusedDeclaration")
    @FooBar
    @PropPresence(Integer.class)
    private static void annotated() {}

    @Test
    public void testFetchValidators() throws Exception {
        // given
        AnnotatedElement target = ValidationsTest.class.getDeclaredMethod("annotated");
        Validations.Instantiator ins = Class::newInstance;

        // when
        List<PropValidator<?>> validators = Validations.fetchValidators(target, ins);

        // then
        assertThat(validators.size(), equalTo(2));
    }
}
@@ -39,63 +39,290 @@
 ort 
-org.junit.Test;%0Aimport org.rocket.network.PropValidator
+com.google.common.collect.ImmutableList;%0Aimport org.junit.Test;%0Aimport org.mockito.InOrder;%0Aimport org.rocket.network.MutProp;%0Aimport org.rocket.network.NetworkClient;%0Aimport org.rocket.network.PropId;%0Aimport org.rocket.network.PropValidator;%0Aimport org.rocket.network.props.PropIds
 ;%0Aim
@@ -618,16 +618,176 @@
 ertThat;
+%0Aimport static org.junit.Assert.fail;%0Aimport static org.mockito.Mockito.inOrder;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;
 %0A%0Apublic
@@ -1252,26 +1252,43 @@
 s = 
-Class::newInstance
+Validations::reflectiveInstantiator
 ;%0A%0A 
@@ -1332,11 +1332,8 @@
 ator
-%3C?%3E
 %3E va
@@ -1458,10 +1458,2221 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testValidateSuccess() throws Exception %7B%0A        // given%0A        NetworkClient client = mock(NetworkClient.class);%0A        AnnotatedElement target = ValidationsTest.class.getDeclaredMethod(%22annotated%22);%0A        List%3CPropValidator%3E validators = Validations.fetchValidators(target, Validations::reflectiveInstantiator);%0A        PropValidator validator = PropValidator.aggregate(ImmutableList.copyOf(validators));%0A%0A        @SuppressWarnings(%22unchecked%22)%0A        MutProp%3CObject%3E strProp = mock(MutProp.class),%0A                intProp = mock(MutProp.class);%0A        PropId strpid = PropIds.type(String.class),%0A                intpid = PropIds.type(Integer.class);%0A%0A        // when%0A        when(strProp.isDefined()).thenReturn(true);%0A        when(intProp.isDefined()).thenReturn(true);%0A%0A        when(client.getProp(strpid)).thenReturn(strProp);%0A        when(client.getProp(intpid)).thenReturn(intProp);%0A%0A        validator.validate(client);%0A%0A        // then%0A        InOrder o = inOrder(client, strProp, intProp);%0A        o.verify(client).getProp(strpid);%0A        o.verify(strProp).isDefined();%0A        o.verify(client).getProp(intpid);%0A        o.verify(intProp).isDefined();%0A        o.verifyNoMoreInteractions();%0A    %7D%0A%0A    @Test(expected = AssertionError.class)%0A    public void testValidateFailure() throws Exception %7B%0A        // given%0A        NetworkClient client = mock(NetworkClient.class);%0A        AnnotatedElement target = ValidationsTest.class.getDeclaredMethod(%22annotated%22);%0A        List%3CPropValidator%3E validators = Validations.fetchValidators(target, Validations::reflectiveInstantiator);%0A        PropValidator validator = PropValidator.aggregate(ImmutableList.copyOf(validators));%0A%0A        @SuppressWarnings(%22unchecked%22)%0A        MutProp%3CObject%3E strProp = mock(MutProp.class),%0A                intProp = mock(MutProp.class);%0A%0A        // when%0A        when(strProp.isDefined()).thenReturn(true);%0A        when(intProp.isDefined()).thenReturn(false);%0A%0A        when(client.getProp(PropIds.type(String.class))).thenReturn(strProp);%0A        when(client.getProp(PropIds.type(Integer.class))).thenReturn(intProp);%0A%0A        validator.validate(client);%0A%0A        // then%0A        fail();%0A%0A    %7D
 %0A%7D

Add tests