Beispiel #1
0
        public void Should_be_managed_by_kevin()
        {
            var expected    = @"this.getDBDateService.ExecuteQuery();
if (condition_2)
{
	return;
}
else if (condition_1)
{
    this.lastValidDateService.ExecuteQuery();
    if (condition_2)
    {
		return;        
    }
}
this.tradeinvalidService.ExecuteQuery();
if (!GOTO_ERROR)
{
	this.sendmailService.ExecuteQuery();
}
this.errorService.ExecuteQuery();
";
            var tibcoParser = new TibcoBWProcessLinqParser();
            var docXml      = XElement.Load("../../ressources/complex_transition.xml");

            var transitions = tibcoParser.ParseTransitions(docXml);

            var codeStatementCollection = this.builder.GenerateMainCodeStatement(transitions, "start", null, this.activitiesToServiceMapping);

            var classesInString = TestCodeGeneratorUtils.GenerateCode(codeStatementCollection);

            Assert.AreEqual(expected, classesInString);
        }
Beispiel #2
0
        public void Should_Return_manage_List_value()
        {
            var xml =
                @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform"" >
    <sqlParams>        
        <param>
            <xsl:value-of select=""'testvalue1'""/>
        </param>
        <param >
            <xsl:value-of select=""'testvalue2'""/>
        </param>
    </sqlParams>  
</pd:inputBindings>
";
            XElement doc = XElement.Parse(xml);

            var generateCode = TestCodeGeneratorUtils.GenerateCode(xslBuilder.Build(doc.Nodes()));

            Assert.AreEqual(@"sqlParams sqlParams = new sqlParams();
sqlParams.param = new List<System.String>();
sqlParams.param.Add(""testvalue1"");
sqlParams.param.Add(""testvalue2"");

", generateCode.ToString());
        }
Beispiel #3
0
        public void Should_Return_void_body_Statement_Of_executeQuery_Method_When_return_type_is_Void_with_One_Param()
        {
            var expected = @"using (IDataAccess db = this.dataAccessFactory.CreateAccess())
{
db.Query(
    sqlQueryStatement,
    new
        {
            idParam = idParam
        }
    );
}

";

            this.jdbcQueryActivity.QueryStatementParameters = new Dictionary <string, string> {
                { "idParam", "System.String" }
            };

            var executeQueryMethod = this.builder.GenerateExecuteQueryMethod(this.jdbcQueryActivity);

            var classesInString = TestCodeGeneratorUtils.GenerateCode(executeQueryMethod);

            Assert.AreEqual(expected, classesInString);
        }
Beispiel #4
0
        public void Should_manage_safeType_when_they_are_child_and_List()
        {
            var packageName = "MyPackage";
            var xml         =
                @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform"" >
    <logInfo>        
        <param>
            <xsl:value-of select=""'testvalue1'""/>
        </param>
        <param>
            <xsl:value-of select=""'testvalue2'""/>
        </param>
    </logInfo>  
</pd:inputBindings>
";
            XElement doc = XElement.Parse(xml);

            var generateCode = TestCodeGeneratorUtils.GenerateCode(this.xslBuilder.Build(packageName, doc.Nodes()));

            Assert.AreEqual(@"MyPackage.logInfo logInfo = new MyPackage.logInfo();
List<System.String> tempparamList = new List<System.String>();
System.String tempparam1;
System.String tempparam2;
tempparam1 = ""testvalue1"";
tempparamList.Add(tempparam1);
tempparam2 = ""testvalue2"";
tempparamList.Add(tempparam2);
logInfo.param = tempparamList.ToArray();

".RemoveWindowsReturnLineChar(), generateCode.ToString().RemoveWindowsReturnLineChar());
        }
        public void Should_Generate_invocation_method_For_inputLoop()
        {
            /**
             *          var expected = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.pe.core.LoopGroup"");
             * for (int index = 0; (index < paramsets.elements.Length); index = (index + 1))
             * {
             * var current = paramsets.elements[index];
             * this.logger.Info(""Start Activity: myNullActivity of type: com.tibco.plugin.timer.NullActivity"");
             * }
             * ";*/
            var expected = @"for (int index = 0; (index < paramsets.elements.Length); index = (index + 1))
{
    var current = paramsets.elements[index];
    this.MyNullActivityCall();
}
";

            this.activity.GroupType            = GroupType.INPUTLOOP;
            this.activity.Over                 = "$Paramsets/elements";
            this.activity.IndexSlot            = "index";
            this.activity.IterationElementSlot = "current";
            this.groupActivityBuilder.GenerateClassesToGenerate(this.activity, null);
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.groupActivityBuilder.GenerateInvocationCode(this.activity, null));

            Assert.AreEqual(expected, generatedCode);
        }
Beispiel #6
0
        public void Should_Generate_invocation_method_When_XsdReference_is_present()
        {
            string expected;

            if (Environment.OSVersion.ToString().Contains("indows"))
            {
                expected =
                    @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.plugin.xml.XMLParseActivity"");
System.String xmlString;
xmlString = ""TestString"";

return this.xmlParserHelperService.FromXml<EquityRecord>(xmlString);
";
            }
            else
            {
                expected = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.plugin.xml.XMLParseActivity"");
System.String xmlString;
xmlString = ""TestString"";

return this.xmlParserHelperService.FromXml <EquityRecord>(xmlString);
";
            }

            var generatedCode = TestCodeGeneratorUtils.GenerateCode(xmlParseActivityBuilder.GenerateMethods(this.activity, null)[0].Statements);

            Assert.AreEqual(expected, generatedCode);
        }
Beispiel #7
0
        public void Should_manage_variable_tag()
        {
            var xml =
                @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform"" xmlns:pfx1=""http://www.SomeWhere.com"">
            <inputs>
                <xsl:variable name=""params"">
                    <xsl:value-of select=""'myvalue'""/>
                </xsl:variable>
                
                <Message>
                    <xsl:value-of select=""concat($Start/pfx3:logInfo/message, ' ', $params)""/>
                </Message>
                
            </inputs>
</pd:inputBindings>
";
            XElement doc = XElement.Parse(xml);

            var codeStatement = xslBuilder.Build(doc.Nodes());

            string generateCode = TestCodeGeneratorUtils.GenerateCode(codeStatement);

            Assert.AreEqual(@"inputs inputs = new inputs();

System.String @params = ""myvalue"";
inputs.Message = TibcoXslHelper.Concat(start_logInfo.message, "" "", @params);

".RemoveWindowsReturnLineChar(), generateCode.RemoveWindowsReturnLineChar());
        }
        public void Should_generate_SubscriberInterface()
        {
            var expected      = @"namespace MyApp.Tools.EventSourcing
{
    using System;
    
    
    public interface ISubscriber
    {
        
        System.Int32 WaitingTimeLimit { get; }
        System.Boolean IsStarted { get; }
        event EventHandler ResponseReceived;
        
        void Start();
        
        void Stop();
        
        void Confirm();
    }
}
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.subscriberBuilder.GenerateClasses()[0]);

            Assert.AreEqual(expected.RemoveWindowsReturnLineChar(), generatedCode);
        }
Beispiel #9
0
        public void Should_Return_ERROR_Start_Method_Body()
        {
            var expected       = @"try
{
    this.step1Service.ExecuteQuery();
}
catch (System.Exception ex)
{
    this.step2Service.ExecuteQuery();
}
this.step3Service.ExecuteQuery();
return;
";
            var tibcoBWProcess = new TibcoBWProcess("MyTestProcess");

            tibcoBWProcess.StartActivity = new Activity("start", ActivityType.startType);
            tibcoBWProcess.EndActivity   = new Activity("End", ActivityType.endType);
            tibcoBWProcess.Transitions   = this.errorProcessTransitions;

            var codeStatementCollection = this.builder.GenerateMainCodeStatement(tibcoBWProcess.Transitions, tibcoBWProcess.StartActivity.Name, null, activitiesToServiceMapping);

            var classesInString = TestCodeGeneratorUtils.GenerateCode(codeStatementCollection);

            Assert.AreEqual(expected, classesInString);
        }
Beispiel #10
0
        public void Should_Return_Complex_Start_Method_Body()
        {
            var expected       = @"if (isCondition1)
{
    this.step1Service.ExecuteQuery();
    this.step3Service.ExecuteQuery();
}
else
{
    this.step2Service.ExecuteQuery();
}
return;
";
            var tibcoBWProcess = new TibcoBWProcess("MyTestProcess");

            tibcoBWProcess.StartActivity = new Activity("start", ActivityType.startType);
            tibcoBWProcess.EndActivity   = new Activity("End", ActivityType.endType);
            tibcoBWProcess.Transitions   = this.complexProcessTransitions;

            var codeStatementCollection = this.builder.GenerateMainCodeStatement(tibcoBWProcess.Transitions, tibcoBWProcess.StartActivity.Name, null, this.activitiesToServiceMapping);

            var classesInString = TestCodeGeneratorUtils.GenerateCode(codeStatementCollection);

            Assert.AreEqual(expected, classesInString);
        }
Beispiel #11
0
        public void Should_Return_Methodbody_Code_When_Activity_has_no_return_type_And_1_input_parameter()
        {
            var xml =
                @"<inputBindings>
        <jdbcQueryActivityInput xmlns:xsl=""http://w3.org/1999/XSL/Transform"">
            <IdBbUnique xmlns:xsl=""http://w3.org/1999/XSL/Transform"">
                <xsl:value-of select=""'test'""/>
            </IdBbUnique>
        </jdbcQueryActivityInput>
</inputBindings>
";
            XElement doc = XElement.Parse(xml);

            this.jdbcQueryActivity.InputBindings = doc.Nodes();
            jdbcQueryActivity.Parameters         = new List <ClassParameter> {
                new ClassParameter {
                    Name = "IdBbUnique", Type = "string"
                }
            };
            this.jdbcQueryActivityBuilder.ServiceToInvoke = "MyService";

            CodeStatementCollection invocationExpression = jdbcQueryActivityBuilder.GenerateMethods(this.jdbcQueryActivity, new Dictionary <string, string>())[0].Statements;

            Assert.AreEqual(
                @"this.logger.Info(""Start Activity: Currency of type: com.tibco.plugin.jdbc.JDBCQueryActivity"");
System.String IdBbUnique;
IdBbUnique = ""test"";

this.myService.ExecuteQuery(IdBbUnique);
", TestCodeGeneratorUtils.GenerateCode(invocationExpression));
        }
Beispiel #12
0
        public void Should_Generate_invocation_method_When_XsdReference_is_not_present()
        {
            this.activity.XsdReference = null;
            var      xsdElement = "<term xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<xsd:element name=\"EquityRecord\" ><xsd:complexType><xsd:sequence><xsd:element name=\"adminID\" type=\"xsd:string\" /></xsd:sequence></xsd:complexType></xsd:element>\n</term>";
            XElement doc        = XElement.Parse(xsdElement);

            this.activity.ObjectXNodes = doc.Nodes();

            string expected;

            if (Environment.OSVersion.ToString().Contains("indows"))
            {
                expected =
                    @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.plugin.xml.XMLParseActivity"");
System.String xmlString;
xmlString = ""TestString"";

return this.xmlParserHelperService.FromXml<MyApp.Mydomain.Service.Contract.My_Activity_Name.EquityRecord>(xmlString);
";
            }
            else
            {
                expected = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.plugin.xml.XMLParseActivity"");
System.String xmlString;
xmlString = ""TestString"";

return this.xmlParserHelperService.FromXml <MyApp.Mydomain.Service.Contract.My_Activity_Name.EquityRecord>(xmlString);
";
            }

            var generatedCode = TestCodeGeneratorUtils.GenerateCode(xmlParseActivityBuilder.GenerateMethods(this.activity, null)[0].Statements);

            Assert.AreEqual(expected, generatedCode);
        }
Beispiel #13
0
        public void Should_Return_1_Variable_assignement_with_2_Levels_Of_Children()
        {
            var xml =
                @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform"">
<sqlParams>  
    <FundCompany>      
        <FundName>
            <xsl:value-of select=""'testvalue'""/>
        </FundName>
    </FundCompany> 
        <AdminID>
            <xsl:value-of select=""'EVL'""/>
        </AdminID>
</sqlParams>  
</pd:inputBindings>
";
            XElement doc = XElement.Parse(xml);

            var generateCode = TestCodeGeneratorUtils.GenerateCode(xslBuilder.Build(doc.Nodes()));

            Assert.AreEqual(@"sqlParams sqlParams = new sqlParams();
sqlParams.FundCompany = new FundCompany();
sqlParams.FundCompany.FundName = ""testvalue"";
sqlParams.AdminID = ""EVL"";

", generateCode.ToString());
        }
Beispiel #14
0
        public void Should_manage_Choose_condition()
        {
            var xml =
                @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform"">
<xsl:choose>
    <xsl:when test=""true"">        
        <FundName>
                <xsl:value-of select=""'testvalue1'""/>
            </FundName>
    </xsl:when>
    <xsl:otherwise>        
        <FundName>
                <xsl:value-of select=""'testvalue2'""/>
            </FundName>
    </xsl:otherwise>
</xsl:choose>
</pd:inputBindings>
";
            XElement doc = XElement.Parse(xml);

            var codeStatement = xslBuilder.Build(doc.Nodes());

            string generateCode = TestCodeGeneratorUtils.GenerateCode(codeStatement);

            Assert.AreEqual("if (true)\n{\n    System.String FundName = \"testvalue1\";\n}\nelse\n{\n    System.String FundName = \"testvalue2\";\n}\n\n", generateCode);
        }
Beispiel #15
0
        public void Should_Log_Activity_Start()
        {
            var logCode       = defaultBuilder.GenerateMethods(this.activity, new Dictionary <string, string>());
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(logCode[0].Statements);

            Assert.AreEqual("this.logger.Info(\"Start Activity: test_Activity of type: " + ActivityType.NotHandleYet + "\");\nthis.test_Activity.Execute();\n", generatedCode);
        }
        public void Should_Generate_invocation_method_For_repeatLoop()
        {
            /**
             *          var expected = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.pe.core.LoopGroup"");
             * for (
             * ; !(true);
             * )
             * {
             * this.logger.Info(""Start Activity: myNullActivity of type: com.tibco.plugin.timer.NullActivity"");
             * }
             * ";*/
            var expected = @"for (
; !(true); 
)
{
    this.MyNullActivityCall();
}
";

            this.activity.GroupType       = GroupType.REPEAT;
            this.activity.RepeatCondition = "true";
            this.groupActivityBuilder.GenerateClassesToGenerate(this.activity, null);
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.groupActivityBuilder.GenerateInvocationCode(this.activity, null));

            Assert.AreEqual(expected, generatedCode);
        }
Beispiel #17
0
        public void Should_return_enum_value()
        {
            var codenamespace = this.xsdBuilder.Build("./../../Ressources/Account.xsd");
            var code          = TestCodeGeneratorUtils.GenerateCode(codenamespace);

            Assert.AreEqual("", code);
        }
        public void Should_return_construstor_statements()
        {
            var expected      = @"this.my_Activity_NameRdvPublisher = my_Activity_NameRdvPublisher;
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.activityBuilder.GenerateConstructorCodeStatement(activity));

            Assert.AreEqual(expected, generatedCode);
        }
Beispiel #19
0
        public void Should_return_construstor_statements()
        {
            var expected      = @"this.subscriber = subscriber;
this.subscriber.ResponseReceived += this.OnEvent;
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.activityBuilder.GenerateConstructorCodeStatement(activity));

            Assert.AreEqual(expected, generatedCode);
        }
Beispiel #20
0
        public void Should_Generate_invocation_method()
        {
            var expected      = @"var configName = ""myconfigPath"";
return this.sharedVariableService.Get(configName);
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(activityBuilder.GenerateMethods(this.activity, new Dictionary <string, string>())[0].Statements);

            Assert.IsTrue(generatedCode.EndsWith(expected));
        }
Beispiel #21
0
        public void Should_Generate_invocation_method()
        {
            var expected      = @"this.logger.Info(""Start Activity: MyActivityName of type: com.tibco.pe.core.ConfirmActivity"");
// TODO: Should be this.subscriber.Confirm(message);
this.subscriber.Confirm();
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(activityBuilder.GenerateMethods(this.activity, new Dictionary <string, string>())[0].Statements);

            Assert.AreEqual(expected, generatedCode);
        }
        public void Should_Return_dataAccess_execution_query_Wtih_no_param_When_ReturnType_is_not_void_and_No_param()
        {
            var expected = "this.dataAccess.ExecuteQuery();\n";

            var executeQueryMethod = this.builder.GenerateExecuteQueryMethod(this.jdbcQueryActivity);

            var classesInString = TestCodeGeneratorUtils.GenerateCode(executeQueryMethod);

            Assert.AreEqual(expected, classesInString);
        }
        public void Should_Return_Method_body()
        {
            var expected      = @"System.String xmlString;
xmlString = ""TestString"";

return this.processToCall.start(xmlString);
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.CallProcessActivityBuilder.GenerateMethods(this.activity, new Dictionary <string, string>())[0]);

            Assert.IsTrue(generatedCode.EndsWith(expected));
        }
        public void Should_Generate_invocation_method()
        {
            var expected      = @"this.logger.Info(""Start Activity: MyActivityName of type: com.tibco.plugin.timer.SleepActivity"");
Int32? IntervalInMillisec;
IntervalInMillisec = 3000;

new Timer(IntervalInMillisec);
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(activityBuilder.GenerateMethods(this.activity, null)[0].Statements);

            Assert.AreEqual(expected, generatedCode);
        }
        public void Should_Generate_invocation_method()
        {
            var expected      = @"System.String message;
message = ""testvalue"";

var configName = ""myconfigPath"";
this.sharedVariableService.Set(configName, message);
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(activityBuilder.GenerateMethods(this.activity, null)[0].Statements);

            Assert.IsTrue(generatedCode.EndsWith(expected));
        }
Beispiel #26
0
        public void Should_Generate_invocation_method_When_XsdReference_is_present()
        {
            var expected      = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.plugin.mapper.MapperActivity"");
EquityRecord EquityRecord = new EquityRecord();

EquityRecord.xmlString = ""TestString"";

return EquityRecord;
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.mapperActivityBuilder.GenerateMethods(this.activity, new Dictionary <string, string>())[0].Statements);

            Assert.AreEqual(expected.RemoveWindowsReturnLineChar(), generatedCode.RemoveWindowsReturnLineChar());
        }
        public void Should_Generate_invocation_method_For_simpleGroup()
        {
            /**
             * var expected = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.pe.core.LoopGroup"");
             * this.MyNullActivityCall();
             * ";*/
            var expected = "this.MyNullActivityCall();\n";

            this.activity.GroupType = GroupType.SIMPLEGROUP;
            this.groupActivityBuilder.GenerateClassesToGenerate(this.activity, null);
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.groupActivityBuilder.GenerateInvocationCode(this.activity, null));

            Assert.AreEqual(expected, generatedCode);
        }
        public void Should_return_invocation_Code()
        {
            var expected      = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.plugin.tibrv.RVPubActivity"");
ActivityInput ActivityInput = new ActivityInput();

ActivityInput.body = ""TestString"";

string subject = ""MY.Tibco.subject"";
this.my_Activity_NameRdvPublisher.Send(subject, ActivityInput);
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(this.activityBuilder.GenerateMethods(this.activity, null)[0].Statements);

            Assert.AreEqual(expected, generatedCode);
        }
        public void Should_Generate_invocation_method()
        {
            var expected      = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.pe.core.WriteToLogActivity"");
System.String message;
System.String msgCode;
message = ""testvalue"";
msgCode = ""EVL"";

this.logger.Error(String.Format(""Message : {0}\nMessage code : {1} "", message, msgCode));
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(activityBuilder.GenerateMethods(this.activity, null)[0].Statements);

            Assert.AreEqual(expected, generatedCode);
        }
        public void Should_Generate_invocation_method()
        {
            var expected      = @"this.logger.Info(""Start Activity: My of type: com.tibco.pe.core.GenerateErrorActivity"");
System.String message;
System.String messageCode;
message = ""testvalue"";
messageCode = ""EVL"";

throw new System.Exception(String.Format(""Message : {0}\nMessage code : {1} "", message, messageCode));
";
            var generatedCode = TestCodeGeneratorUtils.GenerateCode(activityBuilder.GenerateInvocationCode(this.activity, new Dictionary <string, string>()));

            Assert.AreEqual(expected, generatedCode);
        }