use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method methodsAreExtracted2.
@Test
void methodsAreExtracted2() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@Conditional("hasJoined")
@NumberProvider(text = "Test")
public long method() {
return 0;
}
}
Extension extension = new Extension();
ExtensionExtractor underTest = new ExtensionExtractor(extension);
Map<ExtensionMethod.ParameterType, ExtensionMethods> result = underTest.getMethods();
Map<ExtensionMethod.ParameterType, ExtensionMethods> expected = buildExpectedExtensionMethodMap(extension, ExtensionMethods::addNumberMethod);
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method publicProviderMethodsAreRequired.
@Test
void publicProviderMethodsAreRequired() {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@BooleanProvider(text = "Banned")
private boolean method(UUID playerUUID) {
return false;
}
}
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
assertEquals("Extension class had no methods annotated with a Provider annotation", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method methodsAreExtracted6.
@Test
void methodsAreExtracted6() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@TableProvider
public Table method() {
return Table.builder().build();
}
}
Extension extension = new Extension();
ExtensionExtractor underTest = new ExtensionExtractor(extension);
Map<ExtensionMethod.ParameterType, ExtensionMethods> result = underTest.getMethods();
Map<ExtensionMethod.ParameterType, ExtensionMethods> expected = buildExpectedExtensionMethodMap(extension, ExtensionMethods::addTableMethod);
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method textOver50CharsIsWarnedAbout.
@Test
void textOver50CharsIsWarnedAbout() {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@StringProvider(text = "aaaaaAAAAAbbbbbBBBBBcccccCCCCCdddddDDDDDeeeeeEEEEEfffffFFFF")
public String method() {
return "example";
}
}
Extension extension = new Extension();
ExtensionExtractor underTest = new ExtensionExtractor(extension);
assertEquals("Warnings: [Extension.method 'text' was over 50 characters.]", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method dataBuilderProviderMustProvideDataBuilder.
@Test
void dataBuilderProviderMustProvideDataBuilder() {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@DataBuilderProvider
public Group method(UUID playerUUID) {
return null;
}
}
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
assertEquals("Extension.method has invalid return type. was: com.djrapitops.plan.extension.Group, expected: com.djrapitops.plan.extension.builder.ExtensionDataBuilder", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
Aggregations