Пример #1
0
 public ShapeGuiBase(
     int index,
     JsonObject jsonObject,
     Class<? extends IShape> shape,
     StructureTypeGui callback,
     HashMap<String, String> typeMap) {
   super(index, shape.getSimpleName(), jsonObject, typeMap);
   this.callback = callback;
   if (!data.has(BLOCKDATA_KEY)) data.add(BLOCKDATA_KEY, new JsonArray());
   if (!data.has(Shapes.SHAPE_KEY)) data.addProperty(Shapes.SHAPE_KEY, shape.getSimpleName());
 }
Пример #2
0
 private static String getTagName(Class<?> aClass) {
   for (Class<?> c = aClass; c != null; c = c.getSuperclass()) {
     String name = getTagNameFromAnnotation(c);
     if (name != null) {
       return name;
     }
   }
   return aClass.getSimpleName();
 }
 public MethodCallTester<MonitoredClass> assertMethodNotCalled(
     String name, Class<?>... paramTypes) {
   assertFalse(
       "Method "
           + mockClass.getSimpleName()
           + "."
           + name
           + "("
           + Arrays.toString(paramTypes)
           + ") was called but no call was expected",
       wasMethodCalled(name, paramTypes));
   return this;
 }
 public MethodCallTester<MonitoredClass> assertMethodCalled(
     String name, Object... expectedParamValues) {
   assertTrue(
       "Method "
           + mockClass.getSimpleName()
           + "."
           + name
           + "("
           + Arrays.toString(expectedParamValues)
           + ") was not called",
       wasMethodCalled(name, expectedParamValues));
   return this;
 }
 @SuppressWarnings("unused")
 public MethodCallTester<MonitoredClass> assertMethodNotCalled(
     String name, Object... expectedParamValues) {
   assertFalse(
       "Method "
           + mockClass.getSimpleName()
           + "."
           + name
           + "("
           + Arrays.toString(expectedParamValues)
           + ") was called but no call was expected",
       wasMethodCalled(name, expectedParamValues));
   return this;
 }
    /**
     * Check that all methods declared in the given interface were called. Does *not* include
     * methods from super interfaces.
     *
     * @return this for fluent api
     */
    public MethodCallTester<MonitoredClass> assertAllInterfaceMethodsCalled() {
      List<MethodInvocation> currentInvocation =
          new ArrayList<>(invocations); // Debugger calling toString can mess with this
      for (Method method : mockClass.getDeclaredMethods()) {
        if (Modifier.isStatic(method.getModifiers()) || !Modifier.isPublic(method.getModifiers()))
          continue;

        boolean called = false;
        for (MethodInvocation invocation : currentInvocation) {
          if (invocation.method.equals(method.getName())) {
            called = true;
            break;
          }
        }

        assertTrue(
            "Method " + mockClass.getSimpleName() + "." + method.getName() + " was not called",
            called);
      }
      return this;
    }