@Then("^the variable '(\\w+)' should be equal (\\d+.?\\d*)$") public void var_should_equal_float(String name, float expected) { Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT); Project project = ProjectManager.getInstance().getCurrentProject(); UserVariable variable = project.getUserVariables().getUserVariable(name, object); assertNotNull("The variable does not exist.", variable); float actual = variable.getValue().floatValue(); assertThat("The variable is != the value.", actual, equalTo(expected)); }
@And("^this script has a set '(\\w+)' to '(\\w+)' brick$") public void script_has_set_var_to_var_brick(String a, String b) { Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT); Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT); Project project = ProjectManager.getInstance().getCurrentProject(); UserVariable varA = project.getUserVariables().getUserVariable(a, object); if (varA == null) { varA = project.getUserVariables().addSpriteUserVariableToSprite(object, a); } FormulaElement elemB = new FormulaElement(ElementType.USER_VARIABLE, b, null); Brick brick = new SetVariableBrick(new Formula(elemB), varA); script.addBrick(brick); }
@And("^this script has a change '(\\w+)' by (\\d+.?\\d*) brick$") public void script_has_change_var_by_val_brick(String name, String value) { Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT); Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT); Project project = ProjectManager.getInstance().getCurrentProject(); UserVariable variable = project.getUserVariables().getUserVariable(name, object); if (variable == null) { variable = project.getUserVariables().addSpriteUserVariableToSprite(object, name); } FormulaElement elemValue = new FormulaElement(ElementType.NUMBER, value, null); Brick brick = new ChangeVariableBrick(new Formula(elemValue), variable); script.addBrick(brick); }
private void addScriptEndCallbacks() { Project project = ProjectManager.getInstance().getCurrentProject(); for (Sprite sprite : project.getSpriteList()) { for (int i = 0; i < sprite.getNumberOfScripts(); i++) { sprite .getScript(i) .addBrick( new CallbackBrick( sprite, new CallbackBrick.BrickCallback() { @Override public void onCallback() { programWaitLock.release(); } })); } } }
@Test public void hasJavaSourceFiles() { final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); assertThat(fs.hasJavaSourceFiles(), is(true)); PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.java"); project.setConfiguration(conf); assertThat(fs.hasJavaSourceFiles(), is(false)); }
@Test public void applyExclusionPatternsToSourceFiles() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java"); project.setConfiguration(conf); final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); assertThat(fs.getJavaSourceFiles().size(), is(1)); assertThat(fs.getJavaSourceFiles(), hasItem(named("Whizz.java"))); }
@Test public void doNotApplyExclusionPatternsToTestFiles() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java"); project.setConfiguration(conf); final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); assertThat(fs.getTestFiles(Java.INSTANCE).size(), is(1)); assertThat(fs.getTestFiles(Java.INSTANCE), hasItem(named("BarTest.java"))); }
/** See http://jira.codehaus.org/browse/SONAR-1449 */ @Test public void exclusionPatternOnAjFiles() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.aj"); project.setConfiguration(conf); final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); assertThat(fs.getSourceFiles(Java.INSTANCE).size(), is(2)); assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Whizz.java"))); assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Bar.java"))); }
private DefaultProjectFileSystem newDefaultProjectFileSystem(Project project) { return (DefaultProjectFileSystem) project.getFileSystem(); }