Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W-17339665-Add tests to dates parameters types #849

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:munit="http://www.mulesoft.org/schema/mule/munit"
xmlns:munit-tools="http://www.mulesoft.org/schema/mule/munit-tools"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.mulesoft.org/schema/mule/munit-tools http://www.mulesoft.org/schema/mule/munit-tools/current/mule-munit-tools.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">

<munit:config name="select-with-date-parameter-type_mysql-test-case.xml" minMuleVersion="4.3.0" />
<munit:before-suite name="createEmployeesTableForSuite">
<try>
<db:execute-ddl config-ref="dbConfigMySQL">
<db:sql>
<![CDATA[DROP TABLE IF EXISTS EMPLOYEES]]>
</db:sql>
</db:execute-ddl>
<error-handler>
<on-error-continue/>
</error-handler>
</try>
<db:execute-ddl config-ref="dbConfigMySQL">
<db:sql>
<![CDATA[CREATE TABLE EMPLOYEES (employee_id SERIAL PRIMARY KEY,last_name VARCHAR(50),start_time DATE,end_time TIMESTAMP)]]>
</db:sql>
</db:execute-ddl>
<db:insert config-ref="dbConfigMySQL">
<db:sql><![CDATA[INSERT INTO EMPLOYEES VALUES (1, 'Smith', '2024-01-01', '2024-01-01 17:00:00')]]></db:sql>
</db:insert>
<db:insert config-ref="dbConfigMySQL">
<db:sql><![CDATA[INSERT INTO EMPLOYEES VALUES (2, 'Johnson', '2024-02-15', '2024-02-15 09:30:00')]]></db:sql>
</db:insert>
<db:insert config-ref="dbConfigMySQL">
<db:sql><![CDATA[INSERT INTO EMPLOYEES VALUES (3, 'Williams', '2024-03-10', '2024-03-10 12:45:00')]]></db:sql>
</db:insert>
</munit:before-suite>
<munit:after-suite name="deleteEmployeesTable">
<db:execute-ddl config-ref="dbConfigMySQL">
<db:sql>
<![CDATA[DROP TABLE IF EXISTS EMPLOYEES]]>
</db:sql>
</db:execute-ddl>
</munit:after-suite>
<munit:test name="select-with-Date-dataType-test-suiteTest">
<munit:execution >
<set-variable value="2024-02-15" variableName="a_date"/>
<db:select config-ref="dbConfigMySQL">
<db:sql ><![CDATA[SELECT * FROM EMPLOYEES WHERE start_time = :a_date]]></db:sql>
<db:input-parameters ><![CDATA[#[{"a_date": vars.a_date}]]]></db:input-parameters>
</db:select>
</munit:execution>
<munit:validation>
<munit-tools:assert-equals actual="#[sizeOf(payload)]" expected="#[1]"/>
</munit:validation>
</munit:test>
</mule>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<db:sql ><![CDATA[INSERT INTO EMPLOYEES VALUES (102, 'Tr', '01-Jan-2023', '30-Jun-2023')]]></db:sql>
</db:insert>
</munit:before-test>
<munit:test name="select-timestamp-whit-local-timezone-test-suiteTest">
<munit:test name="select-timestamp-whit-local-timezone-test-Test">
<munit:execution >
<set-variable value="2022-10-05T15:39:20.045" variableName="watermark"/>
<db:select config-ref="oracleDbConfig">
Expand All @@ -42,6 +42,19 @@ ORDER BY start_time ASC]]></db:sql>
</munit:validation>
</munit:test>

<munit:test name="select-with-timestamp-parameter-type-Test">
<munit:execution >
<set-variable value="2010-01-01 00:00:00" variableName="watermark"/>
<db:select config-ref="oracleDbConfig">
<db:sql ><![CDATA[SELECT * FROM EMPLOYEES WHERE TO_CHAR(start_time, 'YYYY-MM-DD HH24:MI:SS') = :aStartTime]]></db:sql>
<db:input-parameters ><![CDATA[#[{"aStartTime": vars.watermark}]]]></db:input-parameters>
</db:select>
</munit:execution>
<munit:validation>
<munit-tools:assert-equals actual="#[sizeOf(payload)]" expected="#[1]"/>
</munit:validation>
</munit:test>

<munit:after-test name="dropTable_employees">
<try>
<db:execute-script config-ref="oracleDbConfig">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:munit="http://www.mulesoft.org/schema/mule/munit"
xmlns:munit-tools="http://www.mulesoft.org/schema/mule/munit-tools"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.mulesoft.org/schema/mule/munit-tools http://www.mulesoft.org/schema/mule/munit-tools/current/mule-munit-tools.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">

<munit:config name="select-with-date-parameter-type_postgresql-test-case.xml" minMuleVersion="4.3.0" />
<munit:before-suite name="createEmployeesTableForSuite">
<try>
<db:execute-ddl config-ref="postgres-config">
<db:sql>
<![CDATA[DROP TABLE IF EXISTS EMPLOYEES]]>
</db:sql>
</db:execute-ddl>
<error-handler>
<on-error-continue/>
</error-handler>
</try>
<db:execute-ddl config-ref="postgres-config">
<db:sql>
<![CDATA[CREATE TABLE EMPLOYEES (employee_id SERIAL PRIMARY KEY,last_name VARCHAR(50),start_time DATE,end_time TIMESTAMP)]]>
</db:sql>
</db:execute-ddl>
<db:insert config-ref="postgres-config">
<db:sql><![CDATA[INSERT INTO EMPLOYEES VALUES (1, 'Smith', '2024-01-01', '2024-01-01 17:00:00')]]></db:sql>
</db:insert>
<db:insert config-ref="postgres-config">
<db:sql><![CDATA[INSERT INTO EMPLOYEES VALUES (2, 'Johnson', '2024-02-15', '2024-02-15 09:30:00')]]></db:sql>
</db:insert>
<db:insert config-ref="postgres-config">
<db:sql><![CDATA[INSERT INTO EMPLOYEES VALUES (3, 'Williams', '2024-03-10', '2024-03-10 12:45:00')]]></db:sql>
</db:insert>
</munit:before-suite>
<munit:after-suite name="deleteEmployeesTable">
<db:execute-ddl config-ref="postgres-config">
<db:sql>
<![CDATA[DROP TABLE IF EXISTS EMPLOYEES]]>
</db:sql>
</db:execute-ddl>
</munit:after-suite>
<munit:test name="select-date-datatype-test-suiteTest">
<munit:execution >
<set-variable value="2024-02-15" variableName="a_date"/>
<db:select config-ref="postgres-config">
<db:sql ><![CDATA[SELECT * FROM EMPLOYEES WHERE start_time = :a_date]]></db:sql>
<db:input-parameters ><![CDATA[#[{"a_date": vars.a_date}]]]></db:input-parameters>
</db:select>
</munit:execution>
<munit:validation>
<munit-tools:assert-equals actual="#[sizeOf(payload)]" expected="#[1]"/>
</munit:validation>
</munit:test>
</mule>