Search in sources :

Example 71 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class MavenCentralRepositoryTest method testParse.

@Test
public void testParse() throws Exception {
    @Language("XML") String response = "<response>\n" + "    <lst name=\"responseHeader\">\n" + "        <int name=\"status\">0</int>\n" + "        <int name=\"QTime\">0</int>\n" + "        <lst name=\"params\">\n" + "            <str name=\"spellcheck\">true</str>\n" + "            <str name=\"fl\">\n" + "                id,g,a,latestVersion,p,ec,repositoryId,text,timestamp,versionCount\n" + "            </str>\n" + "            <str name=\"sort\">score desc,timestamp desc,g asc,a asc</str>\n" + "            <str name=\"indent\">off</str>\n" + "            <str name=\"start\">41</str>\n" + "            <str name=\"q\">guice</str>\n" + "            <str name=\"qf\">text^20 g^5 a^10</str>\n" + "            <str name=\"spellcheck.count\">5</str>\n" + "            <str name=\"wt\">xml</str>\n" + "            <str name=\"rows\">5</str>\n" + "            <str name=\"version\">2.2</str>\n" + "            <str name=\"defType\">dismax</str>\n" + "        </lst>\n" + "    </lst>\n" + "    <result name=\"response\" numFound=\"409\" start=\"41\">\n" + "        <doc>\n" + "            <str name=\"a\">guice-bean</str>\n" + "            <arr name=\"ec\">\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <str name=\"g\">org.sonatype.spice.inject</str>\n" + "            <str name=\"id\">org.sonatype.spice.inject:guice-bean</str>\n" + "            <str name=\"latestVersion\">1.3.4</str>\n" + "            <str name=\"p\">pom</str>\n" + "            <str name=\"repositoryId\">central</str>\n" + "            <arr name=\"text\">\n" + "                <str>org.sonatype.spice.inject</str>\n" + "                <str>guice-bean</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <long name=\"timestamp\">1283070402000</long>\n" + "            <int name=\"versionCount\">10</int>\n" + "        </doc>\n" + "        <doc>\n" + "            <str name=\"a\">guice-nexus</str>\n" + "            <arr name=\"ec\">\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <str name=\"g\">org.sonatype.spice.inject</str>\n" + "            <str name=\"id\">org.sonatype.spice.inject:guice-nexus</str>\n" + "            <str name=\"latestVersion\">0.1.0</str>\n" + "            <str name=\"p\">pom</str>\n" + "            <str name=\"repositoryId\">central</str>\n" + "            <arr name=\"text\">\n" + "                <str>org.sonatype.spice.inject</str>\n" + "                <str>guice-nexus</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <long name=\"timestamp\">1267701468000</long>\n" + "            <int name=\"versionCount\">1</int>\n" + "        </doc>\n" + "        <doc>\n" + "            <str name=\"a\">jersey2-guice</str>\n" + "            <arr name=\"ec\">\n" + "                <str>-sources.jar</str>\n" + "                <str>-javadoc.jar</str>\n" + "                <str>.jar</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <str name=\"g\">be.fluid-it.com.squarespace.jersey2-guice</str>\n" + "            <str name=\"id\">\n" + "                be.fluid-it.com.squarespace.jersey2-guice:jersey2-guice\n" + "            </str>\n" + "            <str name=\"latestVersion\">0.10-fix</str>\n" + "            <str name=\"p\">jar</str>\n" + "            <str name=\"repositoryId\">central</str>\n" + "            <arr name=\"text\">\n" + "                <str>be.fluid-it.com.squarespace.jersey2-guice</str>\n" + "                <str>jersey2-guice</str>\n" + "                <str>-sources.jar</str>\n" + "                <str>-javadoc.jar</str>\n" + "                <str>.jar</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <long name=\"timestamp\">1446749364000</long>\n" + "            <int name=\"versionCount\">1</int>\n" + "        </doc>\n" + "        <doc>\n" + "            <str name=\"a\">stdlib-guice-hibernate</str>\n" + "            <arr name=\"ec\">\n" + "                <str>-sources.jar</str>\n" + "                <str>-javadoc.jar</str>\n" + "                <str>.jar</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <str name=\"g\">com.peterphi.std.guice</str>\n" + "            <str name=\"id\">com.peterphi.std.guice:stdlib-guice-hibernate</str>\n" + "            <str name=\"latestVersion\">8.5.1</str>\n" + "            <str name=\"p\">jar</str>\n" + "            <str name=\"repositoryId\">central</str>\n" + "            <arr name=\"text\">\n" + "                <str>com.peterphi.std.guice</str>\n" + "                <str>stdlib-guice-hibernate</str>\n" + "                <str>-sources.jar</str>\n" + "                <str>-javadoc.jar</str>\n" + "                <str>.jar</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <long name=\"timestamp\">1446645753000</long>\n" + "            <int name=\"versionCount\">76</int>\n" + "        </doc>\n" + "        <doc>\n" + "            <str name=\"a\">stdlib-guice-webapp</str>\n" + "            <arr name=\"ec\">\n" + "                <str>-javadoc.jar</str>\n" + "                <str>-sources.jar</str>\n" + "                <str>.jar</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <str name=\"g\">com.peterphi.std.guice</str>\n" + "            <str name=\"id\">com.peterphi.std.guice:stdlib-guice-webapp</str>\n" + "            <str name=\"latestVersion\">8.5.1</str>\n" + "            <str name=\"p\">jar</str>\n" + "            <str name=\"repositoryId\">central</str>\n" + "            <arr name=\"text\">\n" + "                <str>com.peterphi.std.guice</str>\n" + "                <str>stdlib-guice-webapp</str>\n" + "                <str>-javadoc.jar</str>\n" + "                <str>-sources.jar</str>\n" + "                <str>.jar</str>\n" + "                <str>.pom</str>\n" + "            </arr>\n" + "            <long name=\"timestamp\">1446645749000</long>\n" + "            <int name=\"versionCount\">76</int>\n" + "        </doc>\n" + "    </result>\n" + "    <lst name=\"spellcheck\">\n" + "        <lst name=\"suggestions\"/>\n" + "    </lst>\n" + "</response>";
    Reader responseReader = new StringReader(response);
    SearchResult result = new MavenCentralRepository().parse(responseReader);
    assertEquals(409, result.getTotalFound());
    List<String> coordinates = result.getArtifactCoordinates();
    assertThat(coordinates).containsExactly("org.sonatype.spice.inject:guice-bean:1.3.4", "org.sonatype.spice.inject:guice-nexus:0.1.0", "be.fluid-it.com.squarespace.jersey2-guice:jersey2-guice:0.10-fix", "com.peterphi.std.guice:stdlib-guice-hibernate:8.5.1", "com.peterphi.std.guice:stdlib-guice-webapp:8.5.1");
}
Also used : Language(org.intellij.lang.annotations.Language) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) Test(org.junit.Test)

Example 72 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class GradleInstantRunContextTest method multiProcessCheck.

@Test
public void multiProcessCheck() throws Exception {
    @Language("XML") String manifest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "    package=\"co.foo.myapplication\">\n" + "        <activity\n" + "            android:name=\".MainActivity\"\n" + "            android:theme=\"@style/AppTheme.NoActionBar\">\n" + "        </activity>\n" + "</manifest>";
    Document document = XmlUtils.parseDocument(manifest, true);
    assertFalse(GradleInstantRunContext.manifestSpecifiesMultiProcess(document.getDocumentElement(), ImmutableSet.of()));
    manifest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "    package=\"co.foo.myapplication\">\n" + "        <activity\n" + "            android:name=\".MainActivity\"\n" + "            android:process = \":foo\"\n" + "            android:theme=\"@style/AppTheme.NoActionBar\">\n" + "        </activity>\n" + "</manifest>";
    document = XmlUtils.parseDocument(manifest, true);
    assertTrue(GradleInstantRunContext.manifestSpecifiesMultiProcess(document.getDocumentElement(), ImmutableSet.of()));
    manifest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "    package=\"co.foo.myapplication\">\n" + "        <activity\n" + "            android:name=\".MainActivity\"\n" + "            android:process=\":leakcanary\"\n" + "            android:theme=\"@style/AppTheme.NoActionBar\">\n" + "        </activity>\n" + "</manifest>";
    document = XmlUtils.parseDocument(manifest, true);
    assertFalse(GradleInstantRunContext.manifestSpecifiesMultiProcess(document.getDocumentElement(), ImmutableSet.of(":leakcanary")));
    manifest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "    package=\"co.foo.myapplication\">\n" + "     <application>\n" + "        <activity\n" + "            android:name=\".MainActivity\"\n" + "            android:process=\":leakcanary\"\n" + "            android:theme=\"@style/AppTheme.NoActionBar\">\n" + "        </activity>\n" + "        <activity\n" + "            android:name=\".MainActivity\"\n" + "            android:process =\":foo\"\n" + "            android:theme=\"@style/AppTheme.NoActionBar\">\n" + "        </activity>\n" + "    </application>\n" + "</manifest>";
    document = XmlUtils.parseDocument(manifest, true);
    assertTrue(GradleInstantRunContext.manifestSpecifiesMultiProcess(document.getDocumentElement(), ImmutableSet.of(":leakcanary")));
}
Also used : Language(org.intellij.lang.annotations.Language) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 73 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class GradleInstantRunContextTest method getAppResourceReferences.

@Test
public void getAppResourceReferences() throws Exception {
    @Language("XML") String manifest = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "          package=\"com.google.samples.apps.topeka\">\n" + "\n" + "    <application android:allowBackup=\"@bool/allowBackup\"\n" + "                 android:icon=\"@mipmap/ic_launcher\"\n" + "                 android:label=\"@string/app_name\"\n" + "                 android:supportsRtl=\"false\"\n" + "                 android:theme=\"@style/Topeka\"\n" + "                 android:name=\".MyApplication\">\n" + "\n" + "        <activity android:name=\".activity.SignInActivity\"\n" + "                  android:theme=\"@style/Topeka.SignInActivity\">\n" + "            <intent-filter>\n" + "                <action android:name=\"android.intent.action.MAIN\" />\n" + "                <category android:name=\"android.intent.category.LAUNCHER\" />\n" + "            </intent-filter>\n" + "        </activity>\n" + "\n" + "        <activity android:name=\".activity.QuizActivity\"\n" + "                  android:theme=\"@style/Topeka.QuizActivity\"/>\n" + "\n" + "    </application>\n" + "</manifest>";
    Document document = XmlUtils.parseDocument(manifest, false);
    Set<ResourceUrl> appResourceReferences = GradleInstantRunContext.getAppResourceReferences(document.getDocumentElement());
    //noinspection ConstantConditions
    assertEquals(ImmutableList.copyOf(appResourceReferences), ImmutableList.of(ResourceUrl.parse("@bool/allowBackup"), ResourceUrl.parse("@mipmap/ic_launcher"), ResourceUrl.parse("@string/app_name"), ResourceUrl.parse("@style/Topeka"), ResourceUrl.parse("@style/Topeka.QuizActivity"), ResourceUrl.parse("@style/Topeka.SignInActivity")));
}
Also used : Language(org.intellij.lang.annotations.Language) Document(org.w3c.dom.Document) ResourceUrl(com.android.ide.common.resources.ResourceUrl) Test(org.junit.Test)

Example 74 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class LombokPsiConverterTest method testEmptyR.

public void testEmptyR() {
    @Language("JAVA") String testClass = "/*___Generated_by_IDEA___*/\n" + "\n" + "package com.g.android.u;\n" + "\n" + "/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */\n" + "public final class R {\n" + "}";
    PsiFile file = myFixture.addFileToProject("src/com/g/android/u/R.java", testClass);
    check(file, testClass);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Example 75 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class LombokPsiConverterTest method testPrivateEnum2.

public void testPrivateEnum2() {
    @Language("JAVA") String testClass = "package test.pkg;\n" + "\n" + "import com.android.demo.myapplication.R;\n" + "\n" + "public class UnusedReference2 {\n" + "    public enum DocumentBulkAction {\n" + "        UPDATE_ALL() {\n" + "            @Override\n" + "            public int getLabelId() {\n" + "                return R.string.update_all;\n" + "            }\n" + "        };\n" + "\n" + "        public abstract int getLabelId();\n" + "    }\n" + "}\n";
    PsiFile file = myFixture.addFileToProject("src/test/pkg/UnusedReference2.java", testClass);
    check(file, testClass);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Aggregations

Language (org.intellij.lang.annotations.Language)111 TableMetadata (com.facebook.presto.metadata.TableMetadata)25 Test (org.testng.annotations.Test)24 MaterializedResult (com.facebook.presto.testing.MaterializedResult)19 PsiFile (com.intellij.psi.PsiFile)18 MaterializedRow (com.facebook.presto.testing.MaterializedRow)11 List (java.util.List)11 Optional (java.util.Optional)11 Test (org.junit.Test)11 ImmutableList (com.google.common.collect.ImmutableList)10 Session (com.facebook.presto.Session)9 Constraint (com.facebook.presto.spi.Constraint)9 AbstractTestIntegrationSmokeTest (com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)9 BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)8 ColumnConstraint (com.facebook.presto.sql.planner.planPrinter.IOPlanPrinter.ColumnConstraint)8 ImmutableMap (com.google.common.collect.ImmutableMap)8 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)7 ExpectedValueProvider (com.facebook.presto.sql.planner.assertions.ExpectedValueProvider)7 PlanMatchPattern (com.facebook.presto.sql.planner.assertions.PlanMatchPattern)7 SortOrder (com.facebook.presto.common.block.SortOrder)6