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_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 = this.xslBuilder.Build(doc.Nodes()); string generateCode = TestCodeGeneratorUtils.GenerateCode(codeStatement); Assert.AreEqual("System.String FundName;\nif (true)\n{\n FundName = \"testvalue1\";\n}\nelse\n{\n FundName = \"testvalue2\";\n}\n\n", generateCode); }
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); }
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); }
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_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> <parameter> <xsl:value-of select=""'testvalue1'""/> </parameter> <parameter > <xsl:value-of select=""'testvalue2'""/> </parameter> </sqlParams> </pd:inputBindings> "; XElement doc = XElement.Parse(xml); var generateCode = TestCodeGeneratorUtils.GenerateCode(xslBuilder.Build(doc.Nodes())); Assert.AreEqual(@"sqlParams sqlParams = new sqlParams(); List<System.String> tempparameterList = new List<System.String>(); System.String tempparameter1; System.String tempparameter2; tempparameter1 = ""testvalue1""; tempparameterList.Add(tempparameter1); tempparameter2 = ""testvalue2""; tempparameterList.Add(tempparameter2); sqlParams.parameter = tempparameterList.ToArray(); ", generateCode); }
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()); }
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); }
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); }
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)); }
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_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_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 = @"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)); }
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_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() { 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); }
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_Return_dataAccess_execution_query_Wtih_no_param_When_ReturnType_is_not_void_and_has_2_params() { var expected = "this.dataAccess.ExecuteQuery(idBBUnique1, idBBUnique2);\n"; this.jdbcQueryActivity.QueryStatementParameters = new Dictionary <string, string> { { "idBBUnique1", "VARCHAR" }, { "idBBUnique2", "VARCHAR" } }; var executeQueryMethod = this.builder.GenerateExecuteQueryMethod(this.jdbcQueryActivity); var classesInString = TestCodeGeneratorUtils.GenerateCode(executeQueryMethod); Assert.AreEqual(expected, classesInString); }
public void Should_manage_Null_value_when_no_Parent() { var xml = @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> <FundName xsi:nil=""true""/> </pd:inputBindings> "; XElement doc = XElement.Parse(xml); var codeStatement = xslBuilder.Build(doc.Nodes()); string generateCode = TestCodeGeneratorUtils.GenerateCode(codeStatement); Assert.AreEqual( @"object FundName = null; ", generateCode); }
public void Should_Generate_invocation_method() { var expected = @"this.logger.Info(""Start Activity: My_Activity_Name of type: com.tibco.plugin.java.JavaActivity""); System.String platform; platform = ""testvalue""; My.Package.Name.MyJavaFileName myJavaFileName = new My.Package.Name.MyJavaFileName(); myJavaFileName.setplatform(platform); myJavaFileName.Invoke(); My.Package.Name.My_Activity_Name my_Activity_Name = new My.Package.Name.My_Activity_Name(); my_Activity_Name.lastDate = myJavaFileName.getlastDate(); "; var generatedCode = TestCodeGeneratorUtils.GenerateCode(activityBuilder.GenerateMethods(this.activity, new Dictionary <string, string>())[0].Statements); Assert.AreEqual(expected, generatedCode); }
public void Should_Generate_Constructor_CodeStatement() { string expected = @"propertyName1 = ""my test value""; propertyName2 = 12; "; string actual = string.Empty; foreach (var member in resultNamspace.Types[0].Members) { if (member.GetType() == typeof(CodeConstructor)) { var constructor = (CodeConstructor)member; actual = TestCodeGeneratorUtils.GenerateCode(constructor.Statements); } } Assert.AreEqual(expected, actual); }
public void Should_Return_simple_Constructor_When_NoActivies_are_declared() { var expected = "this.logger = logger;\n"; var classToGenerate = this.tibcoBwProcessBuilder.Build(this.tibcoBwProcess); string classesInString = string.Empty; foreach (var member in classToGenerate.Namespaces[0].Types [0].Members) { if (member is CodeConstructor) { classesInString = TestCodeGeneratorUtils.GenerateCode(((CodeConstructor)member).Statements); } } Assert.AreEqual(expected, classesInString); }
public void Should_Return_Simple_Start_Method_Body() { var expected = @"this.step1Service.ExecuteQuery(); return; "; var tibcoBWProcess = new TibcoBWProcess("MyTestProcess"); tibcoBWProcess.StartActivity = new Activity("start", ActivityType.startType); tibcoBWProcess.EndActivity = new Activity("End", ActivityType.endType); tibcoBWProcess.Transitions = this.simpleProcessTransitions; var codeStatementCollection = this.builder.GenerateMainCodeStatement(tibcoBWProcess.Transitions, tibcoBWProcess.StartActivity.Name, null, activitiesToServiceMapping); var classesInString = TestCodeGeneratorUtils.GenerateCode(codeStatementCollection); Assert.AreEqual(expected, classesInString); }
public void Should_Return_1_Variable_assignement_with_DateTime_Type() { var xml = @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform""> <FundName> <xsl:value-of select=""tib:parse-dateTime('MMM dd yyyy', $Mystuff)""/> </FundName> </pd:inputBindings> "; XElement doc = XElement.Parse(xml); var codeStatement = xslBuilder.Build(doc.Nodes()); string generateCode = TestCodeGeneratorUtils.GenerateCode(codeStatement); Assert.AreEqual("DateTime FundName = TibcoXslHelper.ParseDateTime(\"MMM dd yyyy\", Mystuff);\n\n", generateCode); }
public void Should_Return_void_body_Statement_Of_executeQuery_Method_When_return_type_is_Void_with_No_Param() { var expected = @"using (IDataAccess db = this.dataAccessFactory.CreateAccess()) { db.Query( sqlQueryStatement); } "; var executeQueryMethod = this.builder.GenerateExecuteQueryMethod(this.jdbcQueryActivity); var classesInString = TestCodeGeneratorUtils.GenerateCode(executeQueryMethod); Assert.AreEqual(expected, classesInString); }
public void Should_manage_NOT_add_package_name_When_type_is_basic_and_when_its_inputed() { var packageName = "string."; var xml = @"<pd:inputBindings xmlns:pd=""http://xmlns.tibco.com/bw/process/2003"" xmlns:xsl=""http://w3.org/1999/XSL/Transform"" > <param> <xsl:value-of select=""'testvalue1'""/> </param> </pd:inputBindings> "; XElement doc = XElement.Parse(xml); var generateCode = TestCodeGeneratorUtils.GenerateCode(xslBuilder.Build(packageName, doc.Nodes())); Assert.AreEqual("System.String param = \"testvalue1\";\n\n", generateCode.ToString()); }
public void Should_manage_add_the_dot_At_the_end_Of_package_name_When_its_missing() { var packageName = "MyPackage"; 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> </sqlParams> </pd:inputBindings> "; XElement doc = XElement.Parse(xml); var generateCode = TestCodeGeneratorUtils.GenerateCode(xslBuilder.Build(packageName, doc.Nodes())); Assert.AreEqual("MyPackage.sqlParams sqlParams = new MyPackage.sqlParams();\nsqlParams.param = \"testvalue1\";\n\n", generateCode.ToString()); }