Skip to content

Commit

Permalink
ROASTER-33: Added tests to assert Boolean conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Sep 11, 2014
1 parent 47e58d6 commit 2714f84
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,41 @@
*/
public class JavaClassPropertyTest
{
public JavaClassSource getSource()
@Test
public void testProperties()
{
InputStream stream = JavaClassTest.class
.getResourceAsStream("/org/jboss/forge/grammar/java/MockUnformattedClass.java");
return Roaster.parse(JavaClassSource.class, stream);
JavaClassSource source = Roaster.parse(JavaClassSource.class, stream);
List<PropertySource<JavaClassSource>> properties = source.getProperties();
Assert.assertEquals(2, properties.size());
}

@Test
public void testProperties()
public void testPrimitiveBooleanProperties()
{
List<PropertySource<JavaClassSource>> properties = getSource().getProperties();
InputStream stream = JavaClassTest.class
.getResourceAsStream("/org/jboss/forge/grammar/java/BooleanPrimitiveClass.java");
JavaClassSource source = Roaster.parse(JavaClassSource.class, stream);
List<PropertySource<JavaClassSource>> properties = source.getProperties();
Assert.assertEquals(2, properties.size());
Assert.assertNotNull(source.getProperty("myString").getAccessor());
Assert.assertNotNull(source.getProperty("myString").getMutator());
Assert.assertNotNull(source.getProperty("myBoolean").getAccessor());
Assert.assertNotNull(source.getProperty("myBoolean").getMutator());
}

@Test
public void testBooleanProperties()
{
InputStream stream = JavaClassTest.class
.getResourceAsStream("/org/jboss/forge/grammar/java/BooleanClass.java");
JavaClassSource source = Roaster.parse(JavaClassSource.class, stream);
List<PropertySource<JavaClassSource>> properties = source.getProperties();
Assert.assertEquals(2, properties.size());
Assert.assertNotNull(source.getProperty("myString").getAccessor());
Assert.assertNotNull(source.getProperty("myString").getMutator());
Assert.assertNotNull(source.getProperty("myBoolean").getAccessor());
Assert.assertNotNull(source.getProperty("myBoolean").getMutator());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.grammar.java;

public class BooleanClass
{
private String myString;
private Boolean myBoolean;

public String getMyString()
{
return myString;
}

public void setMyString(String myString)
{
this.myString = myString;
}

public Boolean getMyBoolean()
{
return myBoolean;
}

public void setMyBoolean(Boolean myBoolean)
{
this.myBoolean = myBoolean;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.grammar.java;

public class BooleanPrimitiveClass
{
private String myString;
private boolean myBoolean;

public String getMyString()
{
return myString;
}

public void setMyString(String myString)
{
this.myString = myString;
}

public boolean isMyBoolean()
{
return myBoolean;
}

public void setMyBoolean(boolean myBoolean)
{
this.myBoolean = myBoolean;
}
}

0 comments on commit 2714f84

Please sign in to comment.