Added a test to ensure consistency between ShopkeepersPlugin and
ShopkeepersAPI. Adjusted Eclipse classpath to make tests work. There seems to be something off with the maven setup for the individual child modules though.master
parent
1392113525
commit
3e888f4d56
12
.classpath
12
.classpath
|
@ -7,9 +7,17 @@
|
|||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="src" path="src/test/java"/>
|
||||
<classpathentry kind="src" output="target/eclipse-test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src/api/java"/>
|
||||
<classpathentry kind="src" path="src/api/test"/>
|
||||
<classpathentry kind="src" output="target/eclipse-test-classes-api" path="src/api/test">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src/api/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
|
|
|
@ -34,6 +34,7 @@ Date format: (YYYY-MM-DD)
|
|||
* Internal: Metrics will also report now whether the settings 'check-shop-interaction-result', 'bypass-spawn-blocking', 'enable-spawn-verifier' and 'increment-villager-statistics' are used.
|
||||
* Internal: Skipping shopkeeper spawning requests for unloaded worlds (should usually not be the case, but we guard against this anyways now).
|
||||
* Internal: Spigot is stopping the conversion of zombie villagers on its own now if the corresponding transform event gets cancelled.
|
||||
* Internal: Added a test to ensure consistency between ShopkeepersPlugin and ShopkeepersAPI.
|
||||
|
||||
* Debugging: Small changes and additions to some debug messages, especially related to shopkeeper interactions and shopkeeper spawning.
|
||||
* Debugging: Added setting 'debug-options', which can be used to enable additional debugging tools.
|
||||
|
|
|
@ -67,5 +67,9 @@
|
|||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -148,7 +148,13 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -100,6 +100,10 @@
|
|||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-legacy</artifactId>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.nisovin.shopkeepers.api;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class APIMirrorTest {
|
||||
|
||||
@Test
|
||||
public void testMatchingMethods() {
|
||||
List<Method> pluginMethods = Arrays.asList(ShopkeepersPlugin.class.getDeclaredMethods()).stream().filter((method) -> {
|
||||
return Modifier.isAbstract(method.getModifiers());
|
||||
}).collect(Collectors.toList());
|
||||
for (Method pluginMethod : pluginMethods) {
|
||||
Method apiMethod = null;
|
||||
try {
|
||||
apiMethod = ShopkeepersAPI.class.getDeclaredMethod(pluginMethod.getName(), pluginMethod.getParameterTypes());
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
Assert.assertNotNull(ShopkeepersAPI.class.getName() + ": Method '" + pluginMethod.getName() + "' missing!", apiMethod);
|
||||
Assert.assertTrue(ShopkeepersAPI.class.getName() + ": Method '" + pluginMethod.getName() + "' is not static!", Modifier.isStatic(apiMethod.getModifiers()));
|
||||
Assert.assertThat(ShopkeepersAPI.class.getName() + ": Method '" + pluginMethod.getName() + "' mismatching return type!",
|
||||
apiMethod.getReturnType(), Matchers.is((Object) pluginMethod.getReturnType()));
|
||||
Assert.assertThat(ShopkeepersAPI.class.getName() + ": Method '" + pluginMethod.getName() + "' mismatching deprecation!",
|
||||
apiMethod.isAnnotationPresent(Deprecated.class), Matchers.is(pluginMethod.isAnnotationPresent(Deprecated.class)));
|
||||
Assert.assertThat(ShopkeepersAPI.class.getName() + ": Method '" + pluginMethod.getName() + "' mismatching exceptions!",
|
||||
apiMethod.getGenericExceptionTypes(), Matchers.is(pluginMethod.getGenericExceptionTypes()));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue