blob: 75b896a9cb0fbbf4fda0d0bb610c892d14a3040d [file] [log] [blame]
<?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="testFindPartyWithSearchParameters" short-description="Test findparty service on certain search parameters" login-required="false">
<set field="searchParams.partyId" value="DemoCustomer"/>
<set field="searchParams.roleTypeId" value="CUSTOMER"/>
<map-to-map map="searchParams" to-map="serviceCtx"/>
<call-service service-name="findParty" in-map-name="serviceCtx">
<results-to-map map-name="partyList"/>
</call-service>
<find-by-primary-key entity-name="PartyRoleDetailAndPartyDetail" map="searchParams" value-field="partyRoleDetailAndPartyDetail"/>
<if-not-empty field="partyRoleDetailAndPartyDetail">
<assert><not><if-empty field="partyList"/></not></assert>
<else>
<assert><if-empty field="partyList"/></assert>
</else>
</if-not-empty>
<check-errors/>
</simple-method>
<simple-method method-name="testFindPartyWithNoSearchParameters" short-description="Test findparty service when no search parameters are passed" login-required="false">
<set field="serviceCtx.lookupFlag" value="Y"/>
<call-service service-name="findParty" in-map-name="serviceCtx">
<result-to-field result-name="partyList"/>
</call-service>
<!-- At least one party will always exists in the system in any case -->
<assert><not><if-empty field="partyList"/></not></assert>
<check-errors/>
</simple-method>
<simple-method method-name="testUpdatePartyCreditCard" short-description="Test updateCreditCard service" login-required="false">
<set field="serviceCtx.partyId" value="DemoCustomer"/>
<find-by-and entity-name="PaymentMethodAndCreditCard" map="serviceCtx" list="paymentMethodAndCreditCards"/>
<filter-list-by-date list="paymentMethodAndCreditCards"/>
<first-from-list list="paymentMethodAndCreditCards" entry="paymentMethodAndCreditCard"/>
<!-- first try with just updating without changing the credit card information -->
<set-service-fields service-name="updateCreditCard" map="paymentMethodAndCreditCard" to-map="serviceCtx"/>
<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="updateCreditCard" in-map-name="serviceCtx">
<result-to-field result-name="paymentMethodId"/>
<result-to-field result-name="oldPaymentMethodId"/>
</call-service>
<clear-field field="paymentMethodAndCreditCard"/>
<entity-one entity-name="PaymentMethodAndCreditCard" value-field="paymentMethodAndCreditCard"/>
<assert>
<not><if-empty field="paymentMethodAndCreditCard"/></not>
<if-compare-field field="paymentMethodId" to-field="oldPaymentMethodId" operator="equals"/>
<if-compare-field field="paymentMethodAndCreditCard.cardType" to-field="serviceCtx.cardType" operator="equals"/>
<if-compare-field field="paymentMethodAndCreditCard.cardNumber" to-field="serviceCtx.cardNumber" operator="equals"/>
</assert>
<check-errors/>
<clear-field field="paymentMethodAndCreditCard"/>
<clear-field field="paymentMethodId"/>
<clear-field field="oldPaymentMethodId"/>
<!-- try now with few changes (cardType, cardNumber in this case), a new record will be created in PaymentMethod, CreditCard entity -->
<set field="serviceCtx.cardType" value="CCT_MASTERCARD"/>
<set field="serviceCtx.cardNumber" value="5500000000000004"/>
<call-service service-name="updateCreditCard" in-map-name="serviceCtx">
<result-to-field result-name="paymentMethodId"/>
<result-to-field result-name="oldPaymentMethodId"/>
</call-service>
<entity-one entity-name="PaymentMethodAndCreditCard" value-field="paymentMethodAndCreditCard"/>
<assert>
<not><if-empty field="paymentMethodAndCreditCard"/></not>
<if-compare-field field="paymentMethodId" to-field="oldPaymentMethodId" operator="not-equals"/>
<if-compare-field field="paymentMethodAndCreditCard.cardType" to-field="serviceCtx.cardType" operator="equals"/>
<if-compare-field field="paymentMethodAndCreditCard.cardNumber" to-field="serviceCtx.cardNumber" operator="equals"/>
</assert>
<check-errors/>
</simple-method>
<simple-method method-name="testUpdateUserPassword" short-description="Test updatePassword service" login-required="false">
<set field="partyId" value="DemoCustomer"/>
<set field="userLoginId" value="DemoCustomer"/>
<call-class-method method-name="findPartyLatestUserLogin" class-name="org.ofbiz.party.party.PartyWorker" ret-field="partyUserLogin">
<field field="partyId" type="java.lang.String"/>
<field field="delegator" type="org.ofbiz.entity.Delegator"/>
</call-class-method>
<set-service-fields service-name="updatePassword" map="partyUserLogin" to-map="serviceCtx"/>
<!-- old details: userLoginId = DemoCustomer, password = ofbiz -->
<set field="serviceCtx.newPassword" value="ofbiz-demo"/>
<set field="serviceCtx.newPasswordVerify" value="ofbiz-demo"/>
<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="updatePassword" in-map-name="serviceCtx">
<result-to-field result-name="updatedUserLogin"/>
</call-service>
<entity-one entity-name="PartyAndUserLogin" value-field="partyAndUserLogin">
<field-map field-name="userLoginId" from-field="partyUserLogin.userLoginId"/>
<field-map field-name="partyId" from-field="partyId"/>
</entity-one>
<assert>
<not><if-empty field="partyAndUserLogin"/></not>
<if-compare-field field="partyUserLogin.currentPassword" to-field="partyAndUserLogin.currentPassword" operator="not-equals"/>
<if-compare-field field="partyAndUserLogin.userLoginId" to-field="userLoginId" operator="equals"/>
</assert>
<check-errors/>
</simple-method>
<simple-method method-name="testCreatePartyRole" short-description="A test to add a role to a party" login-required="false">
<set field="partyId" value="DemoCustomer"/>
<set field="roleTypeId" value="SUPPLIER"/>
<set field="serviceCtx.partyId" from-field="partyId"/>
<set field="serviceCtx.roleTypeId" from-field="roleTypeId"/>
<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="createPartyRole" in-map-name="serviceCtx"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<not><if-empty field="partyRole"/></not>
<if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
<if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
</assert>
<check-errors/>
</simple-method>
<simple-method method-name="testEnsurePartyRole" short-description="A test to ensure the association between a party and a role" login-required="false">
<set field="partyId" value="DemoCustomer"/>
<set field="roleTypeId" value="SUPPLIER"/>
<set field="serviceCtx.partyId" from-field="partyId"/>
<set field="serviceCtx.roleTypeId" from-field="roleTypeId"/>
<entity-one entity-name="UserLogin" value-field="userLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<not><if-empty field="partyRole"/></not>
<if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
<if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
</assert>
<check-errors/>
<set field="serviceCtx.userLogin" from-field="userLogin"/>
<call-service service-name="ensurePartyRole" in-map-name="serviceCtx"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<not><if-empty field="partyRole"/></not>
<if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
<if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
</assert>
<check-errors/>
<set field="roleTypeId" value="EMPLOYEE"/>
<set field="serviceCtx.roleTypeId" from-field="roleTypeId"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<if-empty field="partyRole"/>
</assert>
<check-errors/>
<call-service service-name="ensurePartyRole" in-map-name="serviceCtx"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<not><if-empty field="partyRole"/></not>
<if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
<if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
</assert>
<check-errors/>
<!-- test ensure from -->
<set field="ensurePartyRoleFromCtx.userLogin" from-field="userLogin"/>
<set field="roleTypeId" value="CONTRACTOR"/>
<set field="ensurePartyRoleFromCtx.roleTypeIdFrom" from-field="roleTypeId"/>
<set field="ensurePartyRoleFromCtx.partyIdFrom" from-field="partyId"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<if-empty field="partyRole"/>
</assert>
<check-errors/>
<call-service service-name="ensurePartyRoleFrom" in-map-name="ensurePartyRoleFromCtx"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<not><if-empty field="partyRole"/></not>
<if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
<if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
</assert>
<check-errors/>
<!-- test ensure to -->
<set field="ensurePartyRoleToCtx.userLogin" from-field="userLogin"/>
<set field="roleTypeId" value="MANUFACTURER"/>
<set field="ensurePartyRoleToCtx.roleTypeIdTo" from-field="roleTypeId"/>
<set field="ensurePartyRoleToCtx.partyIdTo" from-field="partyId"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<if-empty field="partyRole"/>
</assert>
<check-errors/>
<call-service service-name="ensurePartyRoleTo" in-map-name="ensurePartyRoleToCtx"/>
<entity-one entity-name="PartyRole" value-field="partyRole"/>
<assert>
<not><if-empty field="partyRole"/></not>
<if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
<if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
</assert>
<check-errors/>
</simple-method>
<simple-method method-name="testCreateNewCommEvent" short-description="test to create a new communication event" login-required="false">
<set field="createNewCommEventMap.communicationEventTypeId" value="EMAIL_COMMUNICATION"/>
<set field="createNewCommEventMap.statusId" value="COM_ENTERED"/>
<set field="createNewCommEventMap.partyIdFrom" value="DemoCustomer"/>
<set field="createNewCommEventMap.contactMechTypeId" value="EMAIL_ADDRESS"/>
<entity-one entity-name="UserLogin" value-field="createNewCommEventMap.userLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<call-service service-name="createCommunicationEvent" in-map-name="createNewCommEventMap">
<result-to-field result-name="communicationEventId" field="commEventMap.communicationEventId"/>
</call-service>
<call-simple-method method-name="inlineUpdateCommEvent"/>
<entity-one entity-name="CommunicationEvent" value-field="communicationEvent">
<field-map field-name="communicationEventId" from-field="commEventMap.communicationEventId"/>
</entity-one>
<assert>
<not><if-empty field="communicationEvent"/></not>
<if-compare-field field="communicationEvent.communicationEventId" to-field="commEventMap.communicationEventId" operator="equals"/>
<if-compare-field field="communicationEvent.communicationEventTypeId" to-field="updateCommEventMap.communicationEventTypeId" operator="equals"/>
<if-compare-field field="communicationEvent.statusId" to-field="updateCommEventMap.statusId" operator="equals"/>
<if-compare-field field="communicationEvent.partyIdFrom" to-field="updateCommEventMap.partyIdFrom" operator="equals"/>
<if-compare-field field="communicationEvent.contactMechTypeId" to-field="updateCommEventMap.contactMechTypeId" operator="equals"/>
</assert>
<check-errors/>
</simple-method>
<simple-method method-name="inlineUpdateCommEvent" short-description="test to update communication event" login-required="false">
<set field="updateCommEventMap.communicationEventId" from-field="commEventMap.communicationEventId"/>
<set field="updateCommEventMap.communicationEventTypeId" value="AUTO_EMAIL_COMM"/>
<set field="updateCommEventMap.statusId" value="COM_COMPLETE"/>
<set field="updateCommEventMap.partyIdFrom" value="admin"/>
<set field="updateCommEventMap.contactMechTypeId" value="ELECTRONIC_ADDRESS"/>
<entity-one entity-name="UserLogin" value-field="updateCommEventMap.userLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<call-service service-name="updateCommunicationEvent" in-map-name="updateCommEventMap"/>
<check-errors/>
</simple-method>
<simple-method method-name="testCreatePartyTelecomNumber" short-description="Test createPartyTelecomNumber service" login-required="false">
<set field="partyId" value="DemoCustomer"/>
<set field="serviceCtx.partyId" from-field="partyId"/>
<set field="serviceCtx.contactMechPurposeTypeId" value="PRIMARY_PHONE"/>
<set field="serviceCtx.countryCode" value="1"/>
<set field="serviceCtx.areaCode" value="801"/>
<set field="serviceCtx.contactNumber" value="888-8888"/>
<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>
<assert><not><if-empty field="contactMechId"/></not></assert>
<entity-one entity-name="ContactMech" value-field="contactMech"/>
<assert><not><if-empty field="contactMech"/></not></assert>
<entity-one entity-name="TelecomNumber" value-field="telecomNumber"/>
<assert>
<not><if-empty field="telecomNumber"/></not>
<if-compare field="telecomNumber.countryCode" operator="equals" value="1"/>
<if-compare field="telecomNumber.areaCode" operator="equals" value="801"/>
<if-compare field="telecomNumber.contactNumber" operator="equals" value="888-8888"/>
</assert>
<entity-and entity-name="PartyContactMech" list="pcmList" filter-by-date="true">
<field-map field-name="partyId"/>
<field-map field-name="contactMechId"/>
</entity-and>
<assert><not><if-empty field="pcmList"/></not></assert>
<entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true">
<field-map field-name="partyId"/>
<field-map field-name="contactMechId"/>
</entity-and>
<assert><not><if-empty field="pcmpList"/></not></assert>
<first-from-list list="pcmpList" entry="pcmp"/>
<assert><if-compare field="pcmp.contactMechPurposeTypeId" operator="equals" value="PRIMARY_PHONE"/></assert>
<check-errors/>
</simple-method>
<simple-method method-name="testCreatePerson" short-description="Test case for service createPerson" login-required="false">
<set field="firstName" value="Demo"/>
<set field="lastName" value="Person"/>
<set field="serviceCtx.firstName" from-field="firstName"/>
<set field="serviceCtx.lastName" from-field="lastName"/>
<call-service service-name="createPerson" in-map-name="serviceCtx">
<result-to-field result-name="partyId"/>
</call-service>
<entity-one entity-name="Party" value-field="party"/>
<entity-one entity-name="Person" value-field="person"/>
<assert>
<not><if-empty field="party"/></not>
<if-compare field="party.partyTypeId" operator="equals" value="PERSON"/>
<not><if-empty field="person"/></not>
<if-compare-field field="person.firstName" operator="equals" to-field="firstName"/>
<if-compare-field field="person.lastName" operator="equals" to-field="lastName"/>
</assert>
<check-errors/>
</simple-method>
<simple-method method-name="testCreateUpdatePersonWithCreate" short-description="Test the service to create a person" login-required="false">
<set field="serviceCtx.partyId" value="DemoPerson1"/>
<set field="serviceCtx.firstName" value="Demo"/>
<set field="serviceCtx.lastName" value="Person1"/>
<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="createUpdatePerson" in-map-name="serviceCtx">
<result-to-field result-name="partyId"/>
</call-service>
<entity-one entity-name="Party" value-field="party"/>
<entity-one entity-name="Person" value-field="person"/>
<assert>
<not><if-empty field="party"/></not>
<if-compare field="person.firstName" operator="equals" value="Demo"/>
<if-compare field="person.lastName" operator="equals" value="Person1"/>
</assert>
<check-errors/>
</simple-method>
<simple-method method-name="testCreateUpdatePersonWithUpdate" short-description="Test the service to update a person" login-required="false">
<set field="serviceCtx.partyId" value="DemoPerson1"/>
<set field="serviceCtx.firstName" value="Demo"/>
<set field="serviceCtx.lastName" value="Person2"/>
<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="createUpdatePerson" in-map-name="serviceCtx">
<result-to-field result-name="partyId"/>
</call-service>
<entity-one entity-name="Party" value-field="party"/>
<entity-one entity-name="Person" value-field="person"/>
<assert>
<not><if-empty field="party"/></not>
<not><if-empty field="person"/></not>
<if-compare field="person.firstName" operator="equals" value="Demo"/>
<if-compare field="person.lastName" operator="equals" value="Person2"/>
</assert>
<check-errors/>
</simple-method>
</simple-methods>