use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.
the class BallerinaRunConfigurationProducerTest method testMainWithPackageRunConfiguration.
public void testMainWithPackageRunConfiguration() {
PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test; <caret>\nfunction main() {}");
myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
PsiElement element = file.findElementAt(myFixture.getCaretOffset());
assertNotNull(element);
ConfigurationContext configurationContext = new ConfigurationContext(element);
BallerinaApplicationRunConfigurationProducer producer = new BallerinaApplicationRunConfigurationProducer();
BallerinaApplicationConfiguration runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath());
assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath() + "_vl");
assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.
the class BallerinaRunConfigurationProducerTest method testMainWithPackageRunConfigurationFromContext.
public void testMainWithPackageRunConfigurationFromContext() {
PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test;\nfunction <caret>main() {}");
myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
PsiElement element = file.findElementAt(myFixture.getCaretOffset());
assertNotNull(element);
ConfigurationContext configurationContext = new ConfigurationContext(element);
BallerinaApplicationRunConfigurationProducer producer = new BallerinaApplicationRunConfigurationProducer();
ConfigurationFromContext configurationFromContext = producer.createConfigurationFromContext(configurationContext);
assertNotNull(configurationFromContext);
RunConfiguration runConfiguration = configurationFromContext.getConfiguration();
assertTrue(runConfiguration instanceof BallerinaApplicationConfiguration);
BallerinaApplicationConfiguration ballerinaApplicationConfiguration = (BallerinaApplicationConfiguration) runConfiguration;
assertEquals(RunConfigurationKind.MAIN, ballerinaApplicationConfiguration.getRunKind());
assertEquals(file.getVirtualFile().getPath(), ballerinaApplicationConfiguration.getFilePath());
assertEquals("org/test", ballerinaApplicationConfiguration.getPackage());
}
use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.
the class BallerinaRunConfigurationProducerTest method testServiceWithoutPackageRunConfigurationFromContext.
public void testServiceWithoutPackageRunConfigurationFromContext() {
PsiFile file = myFixture.configureByText("a.bal", "service<http> <caret>main {}");
PsiElement element = file.findElementAt(myFixture.getCaretOffset());
assertNotNull(element);
ConfigurationContext configurationContext = new ConfigurationContext(element);
BallerinaApplicationRunConfigurationProducer producer = new BallerinaApplicationRunConfigurationProducer();
ConfigurationFromContext configurationFromContext = producer.createConfigurationFromContext(configurationContext);
assertNotNull(configurationFromContext);
RunConfiguration runConfiguration = configurationFromContext.getConfiguration();
assertTrue(runConfiguration instanceof BallerinaApplicationConfiguration);
BallerinaApplicationConfiguration ballerinaApplicationConfiguration = (BallerinaApplicationConfiguration) runConfiguration;
assertEquals(RunConfigurationKind.SERVICE, ballerinaApplicationConfiguration.getRunKind());
assertEquals(file.getVirtualFile().getPath(), ballerinaApplicationConfiguration.getFilePath());
assertEmpty(ballerinaApplicationConfiguration.getPackage());
}
Aggregations