use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method methodsAreExtracted1.
@Test
void methodsAreExtracted1() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@Conditional("hasJoined")
@BooleanProvider(text = "Test", conditionName = "isBanned")
public boolean method() {
return false;
}
}
Extension extension = new Extension();
ExtensionExtractor underTest = new ExtensionExtractor(extension);
Map<ExtensionMethod.ParameterType, ExtensionMethods> result = underTest.getMethods();
Map<ExtensionMethod.ParameterType, ExtensionMethods> expected = buildExpectedExtensionMethodMap(extension, ExtensionMethods::addBooleanMethod);
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method methodsAreExtracted8.
@Test
void methodsAreExtracted8() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@DataBuilderProvider
public ExtensionDataBuilder method() {
return null;
}
}
Extension extension = new Extension();
ExtensionExtractor underTest = new ExtensionExtractor(extension);
Map<ExtensionMethod.ParameterType, ExtensionMethods> result = underTest.getMethods();
Map<ExtensionMethod.ParameterType, ExtensionMethods> expected = buildExpectedExtensionMethodMap(extension, ExtensionMethods::addDataBuilderMethod);
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method percentageProviderMustReturnPrimitiveDouble.
@Test
void percentageProviderMustReturnPrimitiveDouble() {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@PercentageProvider(text = "Achievements awarded")
public Double method(UUID playerUUID) {
return null;
}
}
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
assertEquals("Extension.method has invalid return type. was: java.lang.Double, expected: double", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method booleanProviderMustReturnPrimitiveBoolean.
@Test
void booleanProviderMustReturnPrimitiveBoolean() {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@BooleanProvider(text = "Banned")
public Boolean method(UUID playerUUID) {
return null;
}
}
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
assertEquals("Extension.method has invalid return type. was: java.lang.Boolean, expected: boolean", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method conditionalMethodRequiresProvider.
@Test
void conditionalMethodRequiresProvider() {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@Conditional("hasJoined")
public boolean method(UUID playerUUID) {
return false;
}
}
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
assertEquals("Extension.method did not have any associated Provider for Conditional.", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
Aggregations