use of javax.tools.JavaFileObject in project DeepLinkDispatch by airbnb.
the class DeepLinkProcessorTest method uppercasePackage.
@Test
public void uppercasePackage() {
JavaFileObject activityWithUppercasePackage = JavaFileObjects.forSourceString("SampleActivity", "package com.Example;" + "import com.airbnb.deeplinkdispatch.DeepLink;\n" + "import com.airbnb.deeplinkdispatch.DeepLinkHandler;\n\n" + "import com.Example.SampleModule;\n\n" + "@DeepLink(\"airbnb://example.com/deepLink\")" + "@DeepLinkHandler({ SampleModule.class })\n" + "public class SampleActivity {\n" + "}");
JavaFileObject module = JavaFileObjects.forSourceString("SampleModule", "package com.Example;" + "import com.airbnb.deeplinkdispatch.DeepLinkModule;\n\n" + "@DeepLinkModule\n" + "public class SampleModule {\n" + "}");
assertAbout(javaSources()).that(Arrays.asList(module, activityWithUppercasePackage)).processedWith(new DeepLinkProcessor()).compilesWithoutError().and().generatesSources(JavaFileObjects.forSourceString("/SOURCE_OUTPUT.com.Example.SampleModuleLoader", "package com.Example;\n" + "\n" + "import com.airbnb.deeplinkdispatch.DeepLinkEntry;\n" + "import com.airbnb.deeplinkdispatch.Parser;\n" + "import java.lang.Override;\n" + "import java.lang.String;\n" + "import java.util.Arrays;\n" + "import java.util.Collections;\n" + "import java.util.List;\n" + "\n" + "public final class SampleModuleLoader implements Parser {\n" + " public static final List<DeepLinkEntry> REGISTRY = " + "Collections.unmodifiableList(Arrays.asList(" + "new DeepLinkEntry(\"airbnb://example.com/deepLink\", DeepLinkEntry.Type" + ".CLASS, SampleActivity.class, null)));\n" + "\n" + " @Override" + " public DeepLinkEntry parseUri(String uri) {\n" + " for (DeepLinkEntry entry : REGISTRY) {\n" + " if (entry.matches(uri)) {\n" + " return entry;\n" + " }\n" + " }\n" + " return null;\n" + " }\n" + "}"));
}
use of javax.tools.JavaFileObject in project DeepLinkDispatch by airbnb.
the class DeepLinkProcessorTest method testProcessor.
@Test
public void testProcessor() {
JavaFileObject sampleActivity = JavaFileObjects.forSourceString("SampleActivity", "package com.example;" + "import com.airbnb.deeplinkdispatch.DeepLink;\n" + "import com.airbnb.deeplinkdispatch.DeepLinkHandler;\n\n" + "import com.example.SampleModule;\n\n" + "@DeepLink(\"airbnb://example.com/deepLink\")\n" + "@DeepLinkHandler({ SampleModule.class })\n" + "public class SampleActivity {\n" + "}");
JavaFileObject module = JavaFileObjects.forSourceString("SampleModule", "package com.example;" + "import com.airbnb.deeplinkdispatch.DeepLinkModule;\n\n" + "@DeepLinkModule\n" + "public class SampleModule {\n" + "}");
assertAbout(javaSources()).that(Arrays.asList(module, sampleActivity)).processedWith(new DeepLinkProcessor()).compilesWithoutError().and().generatesSources(JavaFileObjects.forResource("DeepLinkDelegate.java"), JavaFileObjects.forSourceString("/SOURCE_OUTPUT.com.example.SampleModuleLoader", "package com.example;\n" + "\n" + "import com.airbnb.deeplinkdispatch.DeepLinkEntry;\n" + "import com.airbnb.deeplinkdispatch.Parser;\n" + "import java.lang.Override;\n" + "import java.lang.String;\n" + "import java.util.Arrays;\n" + "import java.util.Collections;\n" + "import java.util.List;\n" + "\n" + "public final class SampleModuleLoader implements Parser {\n" + " public static final List<DeepLinkEntry> REGISTRY = " + "Collections.unmodifiableList(Arrays.asList(" + "new DeepLinkEntry(\"airbnb://example.com/deepLink\", DeepLinkEntry.Type" + ".CLASS, SampleActivity.class, null)));\n" + "\n" + " @Override" + " public DeepLinkEntry parseUri(String uri) {\n" + " for (DeepLinkEntry entry : REGISTRY) {\n" + " if (entry.matches(uri)) {\n" + " return entry;\n" + " }\n" + " }\n" + " return null;\n" + " }\n" + "}"));
}
use of javax.tools.JavaFileObject in project DeepLinkDispatch by airbnb.
the class DeepLinkProcessorTest method testProcessorWithEmptyCustomPrefixFail.
@Test
public void testProcessorWithEmptyCustomPrefixFail() {
JavaFileObject emptyPrefixLink = JavaFileObjects.forSourceString("MyDeepLink", "package com.example;\n" + "import com.airbnb.deeplinkdispatch.DeepLinkSpec;\n" + "@DeepLinkSpec(prefix = { \"http://\", \"\" })\n" + "public @interface MyDeepLink {\n" + " String[] value();\n" + "}");
assertAbout(javaSources()).that(Arrays.asList(emptyPrefixLink, SIMPLE_DEEPLINK_ACTIVITY, SIMPLE_DEEPLINK_MODULE)).processedWith(new DeepLinkProcessor()).failsToCompile().withErrorContaining("Prefix property cannot have null or empty strings");
}
use of javax.tools.JavaFileObject in project epoxy by airbnb.
the class EpoxyProcessorTest method testModelThatDoesNotExtendEpoxyModelFails.
@Test
public void testModelThatDoesNotExtendEpoxyModelFails() {
JavaFileObject model = JavaFileObjects.forResource("ModelWithoutEpoxyExtension.java");
assert_().about(javaSource()).that(model).processedWith(new EpoxyProcessor()).failsToCompile().withErrorContaining("must extend");
}
use of javax.tools.JavaFileObject in project epoxy by airbnb.
the class EpoxyProcessorTest method testGeneratedDefaultMethodWithLayoutSpecifiedInParent.
@Test
public void testGeneratedDefaultMethodWithLayoutSpecifiedInParent() {
JavaFileObject model = JavaFileObjects.forResource("GenerateDefaultLayoutMethodParentLayout.java");
JavaFileObject generatedNoLayoutModel = JavaFileObjects.forResource("GenerateDefaultLayoutMethodParentLayout$NoLayout_.java");
JavaFileObject generatedWithLayoutModel = JavaFileObjects.forResource("GenerateDefaultLayoutMethodParentLayout$WithLayout_.java");
assert_().about(javaSource()).that(model).processedWith(new EpoxyProcessor()).compilesWithoutError().and().generatesSources(generatedNoLayoutModel, generatedWithLayoutModel);
}
Aggregations