Ejemplo n.º 1
0
  private void _classListLocate(Class<?> clazz, List<? extends Annotation> expectedAnnotations) {

    List<Annotation> actualAnnotations = AnnotationLocator.locate(clazz);

    Assert.assertEquals(clazz.getName(), expectedAnnotations.size(), actualAnnotations.size());

    for (int i = 0; i < expectedAnnotations.size(); i++) {
      Annotation expectedAnnotation = expectedAnnotations.get(i);
      Annotation actualAnnotation = actualAnnotations.get(i);

      Assert.assertEquals(
          clazz.getName(), expectedAnnotation.annotationType(), actualAnnotation.annotationType());

      if (expectedAnnotation.annotationType() == Mix.class) {
        Mix expectedMix = (Mix) expectedAnnotation;
        Mix actualMix = (Mix) actualAnnotation;

        Assert.assertEquals("@Mix : " + clazz.getName(), expectedMix.value(), actualMix.value());
      } else {
        Type expectedType = (Type) expectedAnnotation;
        Type actualType = (Type) actualAnnotation;

        Assert.assertEquals("@Type : ", expectedType.value(), actualType.value());
      }
    }
  }
Ejemplo n.º 2
0
  private void _classSingleLocate(Class<?> clazz, int expectedMixValue, int expectedTypeValue) {

    Mix actualMix = AnnotationLocator.locate(clazz, Mix.class);

    if (expectedMixValue == -1) {
      Assert.assertNull("@Mix : " + clazz.getName(), actualMix);
    } else {
      Assert.assertEquals("@Mix : " + clazz.getName(), expectedMixValue, actualMix.value());
    }

    Type actualType = AnnotationLocator.locate(clazz, Type.class);

    if (expectedTypeValue == -1) {
      Assert.assertNull("@Type : " + clazz.getName(), actualType);
    } else {
      Assert.assertEquals("@Type : " + clazz.getName(), expectedTypeValue, actualType.value());
    }
  }
Ejemplo n.º 3
0
  private void _methodSingleLocate(
      Class<?> clazz,
      int[] expectedMethodValues,
      int[] expectedMixValues,
      int[] expectedTypeValues) {

    for (int i = 0; i < 6; i++) {
      java.lang.reflect.Method method = _interfaceMethods[i];
      int expectedMethodValue = expectedMethodValues[i];

      Method methodAnnotation = AnnotationLocator.locate(method, clazz, Method.class);

      if (methodAnnotation == null) {
        Assert.assertEquals("@Method : " + clazz.getName(), -1, expectedMethodValue);

        continue;
      }

      Assert.assertEquals(
          "@Method : " + method.getName() + "()@" + clazz.getName(),
          expectedMethodValue,
          methodAnnotation.value());

      try {
        method = clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());

        methodAnnotation = AnnotationLocator.locate(method, null, Method.class);

        Assert.assertEquals(
            method.getName() + "()@" + clazz.getName(),
            expectedMethodValue,
            methodAnnotation.value());
      } catch (Exception e) {
      }
    }

    for (int i = 0; i < 6; i++) {
      java.lang.reflect.Method method = _interfaceMethods[i];
      int expectedMixValue = expectedMixValues[i];

      Mix mixAnnotation = AnnotationLocator.locate(method, clazz, Mix.class);

      if (mixAnnotation == null) {
        Assert.assertEquals("@Mix : " + clazz.getName(), -1, expectedMixValue);

        continue;
      }

      Assert.assertEquals(
          "@Mix : " + method.getName() + "()@" + clazz.getName(),
          expectedMixValue,
          mixAnnotation.value());

      try {
        method = clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());

        mixAnnotation = AnnotationLocator.locate(method, null, Mix.class);

        Assert.assertEquals(
            method.getName() + "()@" + clazz.getName(), expectedMixValue, mixAnnotation.value());
      } catch (Exception e) {
      }
    }

    for (int i = 0; i < 6; i++) {
      java.lang.reflect.Method method = _interfaceMethods[i];
      int expectedTypeValue = expectedTypeValues[i];

      Type typeAnnotation = AnnotationLocator.locate(method, clazz, Type.class);

      if (typeAnnotation == null) {
        Assert.assertEquals("@Type : " + clazz.getName(), -1, expectedTypeValue);

        continue;
      }

      Assert.assertEquals(
          "@Type : " + method.getName() + "()@" + clazz.getName(),
          expectedTypeValue,
          typeAnnotation.value());

      try {
        method = clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());

        typeAnnotation = AnnotationLocator.locate(method, null, Type.class);

        Assert.assertEquals(
            method.getName() + "()@" + clazz.getName(), expectedTypeValue, typeAnnotation.value());
      } catch (Exception e) {
      }
    }
  }
Ejemplo n.º 4
0
  private void _methodListLocate(Class<?> clazz, List<Annotation[]> expectedAnnotationsList) {

    for (int i = 0; i < _interfaceMethods.length; i++) {
      Annotation[] expectedAnnotations = expectedAnnotationsList.get(i);

      java.lang.reflect.Method method = _interfaceMethods[i];
      List<Annotation> actualAnnotations = AnnotationLocator.locate(method, clazz);

      Assert.assertEquals(
          method.getName() + "()@" + clazz.getName(),
          expectedAnnotations.length,
          actualAnnotations.size());

      for (int j = 0; j < expectedAnnotations.length; j++) {
        Annotation expectedAnnotation = expectedAnnotations[j];
        Annotation actualAnnotation = actualAnnotations.get(j);

        Assert.assertEquals(
            method.getName() + "()@" + clazz.getName(),
            expectedAnnotation.annotationType(),
            actualAnnotation.annotationType());

        if (expectedAnnotation.annotationType() == Mix.class) {
          Mix expectedMix = (Mix) expectedAnnotation;
          Mix actualMix = (Mix) actualAnnotation;

          Assert.assertEquals(
              "@Mix : " + method.getName() + "()@" + clazz.getName(),
              expectedMix.value(),
              actualMix.value());
        } else if (expectedAnnotation.annotationType() == Method.class) {
          Method expectedType = (Method) expectedAnnotation;
          Method actualMethod = (Method) actualAnnotation;

          Assert.assertEquals(
              "@Method : " + method.getName() + "()@" + clazz.getName(),
              expectedType.value(),
              actualMethod.value());
        } else {
          Type expectedType = (Type) expectedAnnotation;
          Type actualType = (Type) actualAnnotation;

          Assert.assertEquals(
              "@Type : " + method.getName() + "()@" + clazz.getName(),
              expectedType.value(),
              actualType.value());
        }
      }

      try {
        method = clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());

        actualAnnotations = AnnotationLocator.locate(method, null);

        Assert.assertEquals(
            method.getName() + "()@" + clazz.getName(),
            expectedAnnotations.length,
            actualAnnotations.size());

        for (int j = 0; j < expectedAnnotations.length; j++) {
          Annotation expectedAnnotation = expectedAnnotations[j];
          Annotation actualAnnotation = actualAnnotations.get(j);

          Assert.assertEquals(
              method.getName() + "()@" + clazz.getName(),
              expectedAnnotation.annotationType(),
              actualAnnotation.annotationType());

          if (expectedAnnotation.annotationType() == Mix.class) {
            Mix expectedMix = (Mix) expectedAnnotation;
            Mix actualMix = (Mix) actualAnnotation;

            Assert.assertEquals(
                "@Mix : " + method.getName() + "()@" + clazz.getName(),
                expectedMix.value(),
                actualMix.value());
          } else if (expectedAnnotation.annotationType() == Method.class) {

            Method expectedType = (Method) expectedAnnotation;
            Method actualMethod = (Method) actualAnnotation;

            Assert.assertEquals(
                "@Method : " + method.getName() + "()@" + clazz.getName(),
                expectedType.value(),
                actualMethod.value());
          } else {
            Type expectedType = (Type) expectedAnnotation;
            Type actualType = (Type) actualAnnotation;

            Assert.assertEquals(
                "@Type : " + method.getName() + "()@" + clazz.getName(),
                expectedType.value(),
                actualType.value());
          }
        }
      } catch (Exception e) {
      }
    }
  }