| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods-v2.xsd"> |
| |
| <simple-method method-name="testUpdatePartyEmailAddress" short-description="Test updatePartyEmailAddress service" login-required="false"> |
| <set field="partyId" value="DemoCustomer"/> |
| <set field="contactMechTypeId" value="EMAIL_ADDRESS"/> |
| <!-- first try with just updating without changing the email address --> |
| <set field="serviceCtx.partyId" from-field="partyId"/> |
| <set field="serviceCtx.emailAddress" value="ofbiztest@example.com"/> |
| <set field="serviceCtx.contactMechId" value="9026"/> |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="system"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| |
| <call-service service-name="updatePartyEmailAddress" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare-field field="contactMechId" to-field="serviceCtx.contactMechId" operator="equals"/> |
| <if-compare-field field="contactMech.infoString" to-field="serviceCtx.emailAddress" operator="equals"/> |
| </assert> |
| <check-errors/> |
| |
| <clear-field field="contactMech"/> |
| <!-- now update with changing the email address, a new record will be created in ContactMech entity this time --> |
| <set field="serviceCtx.emailAddress" value="ofbiz-test@example.com"/> |
| <call-service service-name="updatePartyEmailAddress" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId" field="newContactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"> |
| <field-map field-name="contactMechId" from-field="newContactMechId"/> |
| </entity-one> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare-field field="newContactMechId" to-field="serviceCtx.contactMechId" operator="not-equals"/> |
| <if-compare-field field="contactMech.infoString" to-field="serviceCtx.emailAddress" operator="equals"/> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| <simple-method method-name="testUpdatePartyTelecomNumber" short-description="Test updatePartyTelecomNumber service" login-required="false"> |
| <set field="partyId" value="DemoCustomer"/> |
| <set field="serviceCtx.partyId" from-field="partyId"/> |
| <set field="serviceCtx.contactMechId" value="9025"/> |
| <set field="serviceCtx.countryCode" value="1"/> |
| <set field="serviceCtx.areaCode" value="801"/> |
| <set field="serviceCtx.contactNumber" value="555-5555"/> |
| |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="system"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| |
| <call-service service-name="updatePartyTelecomNumber" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare-field field="contactMechId" to-field="serviceCtx.contactMechId" operator="equals"/> |
| </assert> |
| <clear-field field="telecomNumber"/> |
| <get-related-one value-field="contactMech" relation-name="TelecomNumber" to-value-field="telecomNumber"/> |
| <assert> |
| <not><if-empty field="telecomNumber"/></not> |
| <if-compare-field field="telecomNumber.areaCode" to-field="serviceCtx.areaCode" operator="equals"/> |
| <if-compare-field field="telecomNumber.contactNumber" to-field="serviceCtx.contactNumber" operator="equals"/> |
| </assert> |
| <check-errors/> |
| |
| <clear-field field="contactMech"/> |
| <clear-field field="telecomNumber"/> |
| |
| <!-- try now with changing the telecom number, a new record will be created in ContactMech, TelecomNumber entity this time --> |
| <set field="serviceCtx.contactNumber" value="555-6666"/> |
| <call-service service-name="updatePartyTelecomNumber" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId" field="newContactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"> |
| <field-map field-name="contactMechId" from-field="newContactMechId"/> |
| </entity-one> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare-field field="newContactMechId" to-field="serviceCtx.contactMechId" operator="not-equals"/> |
| </assert> |
| <get-related-one value-field="contactMech" relation-name="TelecomNumber" to-value-field="telecomNumber"/> |
| <assert> |
| <not><if-empty field="telecomNumber"/></not> |
| <if-compare-field field="telecomNumber.contactNumber" to-field="serviceCtx.contactNumber" operator="equals"/> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| <simple-method method-name="testUpdatePartyPostalAddress" short-description="Test updatePartyPostalAddress service" login-required="false"> |
| <set field="partyId" value="DemoCustomer"/> |
| <call-class-method method-name="findPartyLatestPostalAddress" class-name="org.ofbiz.party.party.PartyWorker" ret-field="postalAddress"> |
| <field field="partyId" type="java.lang.String"/> |
| <field field="delegator" type="org.ofbiz.entity.Delegator"/> |
| </call-class-method> |
| <!-- first try with just updating without changing the postal address --> |
| <set-service-fields service-name="updatePartyPostalAddress" map="postalAddress" to-map="serviceCtx"/> |
| <set field="serviceCtx.partyId" from-field="partyId"/> |
| |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="system"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| |
| <call-service service-name="updatePartyPostalAddress" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare-field field="contactMechId" to-field="serviceCtx.contactMechId" operator="equals"/> |
| </assert> |
| <clear-field field="postalAddress"/> |
| <get-related-one value-field="contactMech" relation-name="PostalAddress" to-value-field="postalAddress"/> |
| <assert> |
| <not><if-empty field="postalAddress"/></not> |
| <if-compare-field field="postalAddress.address1" to-field="serviceCtx.address1" operator="equals"/> |
| <if-compare-field field="postalAddress.stateProvinceGeoId" to-field="serviceCtx.stateProvinceGeoId" operator="equals"/> |
| <if-compare-field field="postalAddress.postalCode" to-field="serviceCtx.postalCode" operator="equals"/> |
| </assert> |
| <check-errors/> |
| |
| <clear-field field="contactMech"/> |
| <clear-field field="postalAddress"/> |
| |
| <!-- try now with changing the postal address fields, a new record will be created in ContactMech, PostalAddress entity this time --> |
| <set field="serviceCtx.stateProvinceGeoId" value="VA"/> |
| <set field="serviceCtx.postalCode" value="20147"/> |
| <call-service service-name="updatePartyPostalAddress" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId" field="newContactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"> |
| <field-map field-name="contactMechId" from-field="newContactMechId"/> |
| </entity-one> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare-field field="newContactMechId" to-field="serviceCtx.contactMechId" operator="not-equals"/> |
| </assert> |
| <get-related-one value-field="contactMech" relation-name="PostalAddress" to-value-field="postalAddress"/> |
| <assert> |
| <not><if-empty field="postalAddress"/></not> |
| <if-compare-field field="postalAddress.stateProvinceGeoId" to-field="serviceCtx.stateProvinceGeoId" operator="equals"/> |
| <if-compare-field field="postalAddress.postalCode" to-field="serviceCtx.postalCode" operator="equals"/> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| |
| <simple-method method-name="testCreatePartyEmailAddress" short-description="Test case for service createPartyEmailAddress" login-required="false"> |
| <set field="partyId" value="DemoEmployee"/> |
| <set field="emailAddress" value="demo.employee@gmail.com"/> |
| <set field="contactMechPurposeTypeId" value="PRIMARY_EMAIL"/> |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="system"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| <set field="serviceCtx.partyId" from-field="partyId"/> |
| <set field="serviceCtx.emailAddress" from-field="emailAddress"/> |
| <set field="serviceCtx.contactMechPurposeTypeId" from-field="contactMechPurposeTypeId"/> |
| <call-service service-name="createPartyEmailAddress" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <entity-condition entity-name="PartyContactMech" list="pcmList" filter-by-date="true"> |
| <condition-expr field-name="contactMechId" from-field="contactMechId"/> |
| <order-by field-name="fromDate"/> |
| </entity-condition> |
| <first-from-list list="pcmList" entry="pcm"/> |
| <entity-condition entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <condition-expr field-name="contactMechId" from-field="contactMechId"/> |
| <order-by field-name="fromDate"/> |
| </entity-condition> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare-field field="contactMech.infoString" operator="equals" to-field="emailAddress"/> |
| <not><if-empty field="pcmList"/></not> |
| <if-compare-field field="pcm.partyId" operator="equals" to-field="partyId"/> |
| <not><if-empty field="pcmpList"/></not> |
| <if-compare-field field="pcmp.partyId" operator="equals" to-field="partyId"/> |
| <if-compare-field field="pcmp.contactMechPurposeTypeId" operator="equals" to-field="contactMechPurposeTypeId"/> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| <simple-method method-name="testCreatePartyTelecomNumber" short-description="Test case for service createPartyTelecomNumber" login-required="false"> |
| <set field="serviceCtx.partyId" value="DemoEmployee"/> |
| <set field="serviceCtx.areaCode" value="801"/> |
| <set field="serviceCtx.contactNumber" value="888-8899"/> |
| <set field="serviceCtx.contactMechPurposeTypeId" value="PRIMARY_PHONE"/> |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="system"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| <call-service service-name="createPartyTelecomNumber" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <entity-one entity-name="TelecomNumber" value-field="telecomNumber"/> |
| <entity-and entity-name="PartyContactMech" list="pcmList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmList" entry="pcm"/> |
| <first-from-list list="partyContactMechList" entry="partyContactMech"/> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <not><if-empty field="telecomNumber"/></not> |
| <if-compare field="telecomNumber.areaCode" operator="equals" value="801"/> |
| <if-compare field="telecomNumber.contactNumber" operator="equals" value="888-8899"/> |
| <not><if-empty field="pcmList"/></not> |
| <if-compare field="pcm.partyId" operator="equals" value="DemoEmployee"/> |
| <not><if-empty field="pcmpList"/></not> |
| <if-compare field="pcmp.partyId" operator="equals" value="DemoEmployee"/> |
| <if-compare field="pcmp.contactMechPurposeTypeId" operator="equals" value="PRIMARY_PHONE"/> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| <simple-method method-name="testCreateUpdatePartyTelecomNumberWithCreate" short-description="Test the service for create telecom number" login-required="false"> |
| <set field="serviceCtx.partyId" value="DemoCustomer"/> |
| <set field="serviceCtx.contactMechPurposeTypeId" value="PHONE_WORK"/> |
| <set field="serviceCtx.areaCode" value="801"/> |
| <set field="serviceCtx.contactNumber" value="888-8888"/> |
| <set field="serviceCtx.extension" value="444"/> |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="DemoCustomer"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| <call-service service-name="createUpdatePartyTelecomNumber" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| </call-service> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <entity-one entity-name="TelecomNumber" value-field="telecomNumber"/> |
| <entity-and entity-name="PartyContactMech" list="pcmList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmList" entry="pcm"/> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <not><if-empty field="telecomNumber"/></not> |
| <if-compare field="telecomNumber.areaCode" operator="equals" value="801"/> |
| <if-compare field="telecomNumber.contactNumber" operator="equals" value="888-8888"/> |
| <if-compare field="pcm.extension" operator="equals" value="444"/> |
| <not><if-empty field="pcm"/></not> |
| <not><if-empty field="pcmp"/></not> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| <simple-method method-name="testCreateUpdatePartyTelecomNumberWithUpdate" short-description="Test the service for update telecom number" login-required="false"> |
| <set field="serviceCtx.partyId" value="DemoCustomer"/> |
| <set field="serviceCtx.contactMechId" value="9125"/> |
| <set field="serviceCtx.contactMechPurposeTypeId" value="PHONE_HOME"/> |
| <set field="serviceCtx.areaCode" value="802"/> |
| <set field="serviceCtx.contactNumber" value="555-5555"/> |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="DemoCustomer"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| <call-service service-name="createUpdatePartyTelecomNumber" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| </call-service> |
| <assert> |
| <if-compare field="contactMechId" operator="not-equals" value="9125"/> |
| </assert> |
| <check-errors/> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpListOld"> |
| <field-map field-name="contactMechId" value="9125"/> |
| </entity-and> |
| <first-from-list list="pcmpListOld" entry="pcmpOld"/> |
| <assert> |
| <not><if-empty field="pcmpOld.thruDate"/></not> |
| </assert> |
| <check-errors/> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <entity-one entity-name="TelecomNumber" value-field="telecomNumber"/> |
| <entity-and entity-name="PartyContactMech" list="pcmList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmList" entry="pcm"/> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <not><if-empty field="telecomNumber"/></not> |
| <if-compare field="telecomNumber.areaCode" operator="equals" value="802"/> |
| <if-compare field="telecomNumber.contactNumber" operator="equals" value="555-5555"/> |
| <not><if-empty field="pcm"/></not> |
| <not><if-empty field="pcmp"/></not> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| <simple-method method-name="testCreateUpdatePartyEmailAddressWithCreate" short-description="Test the service for create email address" login-required="false"> |
| <set field="serviceCtx.partyId" value="DemoCustomer"/> |
| <set field="serviceCtx.contactMechPurposeTypeId" value="PRIMARY_EMAIL"/> |
| <set field="serviceCtx.emailAddress" value="demo.customer@foo.com"/> |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="DemoCustomer"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| <call-service service-name="createUpdatePartyEmailAddress" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| <result-to-field result-name="emailAddress"/> |
| </call-service> |
| <assert> |
| <if-compare field="emailAddress" operator="equals" value="demo.customer@foo.com"/> |
| </assert> |
| <check-errors/> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <entity-and entity-name="PartyContactMech" list="pcmList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmList" entry="pcm"/> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare field="contactMech.infoString" operator="equals" value="demo.customer@foo.com"/> |
| <not><if-empty field="pcm"/></not> |
| <not><if-empty field="pcmp"/></not> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| |
| <simple-method method-name="testCreateUpdatePartyEmailAddressWithUpdate" short-description="Test the service for update email address" login-required="false"> |
| <set field="serviceCtx.partyId" value="DemoCustomer"/> |
| <set field="serviceCtx.contactMechId" value="9126"/> |
| <set field="serviceCtx.contactMechPurposeTypeId" value="PRIMARY_EMAIL"/> |
| <set field="serviceCtx.emailAddress" value="demo.customer@foo.com"/> |
| <entity-one entity-name="UserLogin" value-field="userLogin"> |
| <field-map field-name="userLoginId" value="DemoCustomer"/> |
| </entity-one> |
| <set field="serviceCtx.userLogin" from-field="userLogin"/> |
| <call-service service-name="createUpdatePartyEmailAddress" in-map-name="serviceCtx"> |
| <result-to-field result-name="contactMechId"/> |
| <result-to-field result-name="emailAddress"/> |
| </call-service> |
| <assert> |
| <if-compare field="contactMechId" operator="not-equals" value="9126"/> |
| <if-compare field="emailAddress" operator="equals" value="demo.customer@foo.com"/> |
| </assert> |
| <check-errors/> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpListOld"> |
| <field-map field-name="contactMechId" value="9126"/> |
| </entity-and> |
| <first-from-list list="pcmpListOld" entry="pcmpOld"/> |
| <assert> |
| <not><if-empty field="pcmpOld.thruDate"/></not> |
| </assert> |
| <check-errors/> |
| <entity-one entity-name="ContactMech" value-field="contactMech"/> |
| <entity-and entity-name="PartyContactMech" list="pcmList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmList" entry="pcm"/> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId"/> |
| </entity-and> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <assert> |
| <not><if-empty field="contactMech"/></not> |
| <if-compare field="contactMech.infoString" operator="equals" value="demo.customer@foo.com"/> |
| <not><if-empty field="pcm"/></not> |
| <not><if-empty field="pcmp"/></not> |
| </assert> |
| <check-errors/> |
| </simple-method> |
| </simple-methods> |