use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.
the class BallerinaRunConfigurationProducerTest method testMainWithoutPackageRunConfiguration.
public void testMainWithoutPackageRunConfiguration() {
PsiFile file = myFixture.configureByText("a.bal", "<caret>\nfunction main() {}");
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 testMainWithoutPackageRunConfigurationFromContext.
public void testMainWithoutPackageRunConfigurationFromContext() {
PsiFile file = myFixture.configureByText("a.bal", "function <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.MAIN, ballerinaApplicationConfiguration.getRunKind());
assertEquals(file.getVirtualFile().getPath(), ballerinaApplicationConfiguration.getFilePath());
assertEmpty(ballerinaApplicationConfiguration.getPackage());
}
use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.
the class BallerinaRunConfigurationProducerTest method testServiceWithPackageRunConfiguration.
public void testServiceWithPackageRunConfiguration() {
PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test; <caret>\nservice<http> 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 testServiceWithPackageRunConfigurationFromContext.
public void testServiceWithPackageRunConfigurationFromContext() {
PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test;\nservice<http> <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.SERVICE, 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 testServiceWithoutPackageRunConfiguration.
public void testServiceWithoutPackageRunConfiguration() {
PsiFile file = myFixture.configureByText("a.bal", "<caret>\nservice<http> main {}");
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));
}
Aggregations