public void testLoadMockDistro() throws Exception {
File distroDir = TestDataProvider.getTestFile(new Path("testData/mock-puppet-distro/puppet-2.6.2_0/lib/puppet"));
RubyHelper helper = new RubyHelper();
helper.setUp();
try {
TargetEntry target = helper.loadDistroTarget(distroDir);
// check the target itself
assertNotNull("Should have resultet in a TargetEntry", target);
assertEquals("Should have defined description", "Puppet Distribution", target.getDescription());
assertEquals("Should have defined name", "puppet", target.getLabel());
assertEquals("Should have defined version", "2.6.2_0", target.getVersion());
// should have found one type "mocktype"
assertEquals("Should have found one type", 1, target.getTypes().size());
Type type = target.getTypes().get(0);
assertEquals("Should have found 'mocktype'", "mocktype", type.getName());
assertEquals("Should have found documentation", "<p>This is a mock type</p>", type.getDocumentation());
assertEquals("Should have one property", 1, type.getProperties().size());
{
Property prop = getProperty("prop1", type);
assertNotNull("Should have a property 'prop1", prop);
assertEquals("Should have defined documentation", "<p>This is property1</p>", prop.getDocumentation());
}
{
assertEquals("Should have one parameter", 1, type.getParameters().size());
Parameter param = getParameter("param1", type);
assertNotNull("Should have a parameter 'param1", param);
assertEquals("Should have defined documentation", "<p>This is parameter1</p>", param.getDocumentation());
}
// There should be two type fragments, with a contribution each
List<TypeFragment> typeFragments = target.getTypeFragments();
assertEquals("Should have found two fragments", 2, typeFragments.size());
TypeFragment fragment1 = typeFragments.get(0);
TypeFragment fragment2 = typeFragments.get(1);
boolean fragment1HasExtra1 = getProperty("extra1", fragment1) != null;
{
Property prop = getProperty("extra1", fragment1HasExtra1
? fragment1
: fragment2);
assertNotNull("Should have a property 'extra1", prop);
assertEquals(
"Should have defined documentation", "<p>An extra property called extra1</p>",
prop.getDocumentation());
}
{
Property prop = getProperty("extra2", fragment1HasExtra1
? fragment2
: fragment1);
assertNotNull("Should have a property 'extra2", prop);
assertEquals(
"Should have defined documentation", "<p>An extra property called extra2</p>",
prop.getDocumentation());
}
// should have found two functions "echotest" and "echotest2"
// and the log functions (8)
assertEquals("Should have found two functions", 10, target.getFunctions().size());
{
Function f = getFunction("echotest", target);
assertNotNull("Should have found function 'echotest'", f);
assertTrue("echotest should be an rValue", f.isRValue());
}