Skip to content

Commit

Permalink
Updated Mocks.cls class and added build script
Browse files Browse the repository at this point in the history
  • Loading branch information
afawcettffdc committed Mar 29, 2015
1 parent fbf30f7 commit 2857bd7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 126 deletions.
Binary file added bin/apex-mocks-generator-3.1.2.jar
Binary file not shown.
16 changes: 16 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Apex Commons Sample Application" default="generate.mocks" basedir=".">

<target name="generate.mocks">
<java classname="com.financialforce.apexmocks.ApexMockGenerator">
<classpath>
<pathelement location="${basedir}/bin/apex-mocks-generator-3.1.2.jar"/>
</classpath>
<arg value="${basedir}/fflib-sample-code/src/classes"/>
<arg value="${basedir}/interfacemocks.properties"/>
<arg value="Mocks"/>
<arg value="${basedir}/fflib-sample-code/src/classes"/>
</java>
</target>

</project>
150 changes: 24 additions & 126 deletions fflib-sample-code/src/classes/Mocks.cls
Original file line number Diff line number Diff line change
@@ -1,102 +1,25 @@
/*
* FinancialForce.com, inc. claims copyright in this software, its screen
* display designs and supporting documentation. FinancialForce and
* FinancialForce.com are trademarks of FinancialForce.com, inc. Any
* unauthorized use, copying or sale of the above may constitute an
* infringement of copyright and may result in criminal or other legal
* proceedings.
*
* Copyright (c) FinancialForce.com, inc. All rights reserved.
*/

@IsTest
public class Mocks
/* Generated by apex-mocks-generator version 3.1.2 */
@isTest
public class Mocks
{
public class OpportunitiesService
implements IOpportunitiesService

public class OpportunitiesSelector extends fflib_SObjectMocks.SObjectSelector implements IOpportunitiesSelector
{
private fflib_ApexMocks mocks;

public OpportunitiesService(fflib_ApexMocks mocks)
public OpportunitiesSelector(fflib_ApexMocks mocks)
{
super(mocks);
this.mocks = mocks;
}

public void applyDiscounts(Set<ID> opportunityIds, Decimal discountPercentage)
public List<Opportunity> selectByIdWithProducts(Set<ID> idSet)
{
if (mocks.Verifying)
{
mocks.verifyMethodCall(this, 'applyDiscounts', new List<Object> {opportunityIds, discountPercentage});
}
else
{
mocks.recordMethod(this, 'applyDiscounts', new List<Object> {opportunityIds, discountPercentage});
}
}

public Set<Id> createInvoices(Set<ID> opportunityIds, Decimal discountPercentage)
{
if (mocks.Verifying)
{
mocks.verifyMethodCall(this, 'createInvoices', new List<Object> {opportunityIds, discountPercentage});
}
else if (mocks.Stubbing)
{
mocks.prepareMethodReturnValue(this, 'createInvoices', new List<Object> {opportunityIds, discountPercentage});
return null;
}
else
{
mocks.recordMethod(this, 'createInvoices', new List<Object> {opportunityIds, discountPercentage});

fflib_MethodReturnValue methodReturnValue = mocks.getMethodReturnValue(this, 'createInvoices', new List<Object> {opportunityIds, discountPercentage});

if (methodReturnValue != null)
{
if (methodReturnValue.ReturnValue instanceof Exception)
{
throw ((Exception) methodReturnValue.ReturnValue);
}

return (Set<Id>) methodReturnValue.ReturnValue;
}
}
return null;
}

public Id submitInvoicingJob()
{
if (mocks.Verifying)
{
mocks.verifyMethodCall(this, 'submitInvoicingJob', new List<Object> { });
}
else if (mocks.Stubbing)
{
mocks.prepareMethodReturnValue(this, 'submitInvoicingJob', new List<Object> { });
return null;
}
else
{
mocks.recordMethod(this, 'submitInvoicingJob', new List<Object> { });

fflib_MethodReturnValue methodReturnValue = mocks.getMethodReturnValue(this, 'submitInvoicingJob', new List<Object> { });

if (methodReturnValue != null)
{
if (methodReturnValue.ReturnValue instanceof Exception)
{
throw ((Exception) methodReturnValue.ReturnValue);
}

return (Id) methodReturnValue.ReturnValue;
}
}
return null;
return (List<Opportunity>) mocks.mockNonVoidMethod(this, 'selectByIdWithProducts', new List<Object> {idSet});
}
}

public class Opportunities extends fflib_SObjectMocks.SObjectDomain
implements IOpportunities
public class Opportunities extends fflib_SObjectMocks.SObjectDomain implements IOpportunities
{
private fflib_ApexMocks mocks;

Expand All @@ -108,57 +31,32 @@ public class Mocks

public void applyDiscount(Decimal discountPercentage, fflib_ISObjectUnitOfWork uow)
{
if (mocks.Verifying)
{
mocks.verifyMethodCall(this, 'applyDiscount', new List<Object> {discountPercentage, uow});
}
else
{
mocks.recordMethod(this, 'applyDiscount', new List<Object> {discountPercentage, uow});
}
mocks.mockVoidMethod(this, 'applyDiscount', new List<Object> {discountPercentage, uow});
}
}

public class OpportunitiesSelector extends fflib_SObjectMocks.SObjectSelector
implements IOpportunitiesSelector
public class OpportunitiesService implements IOpportunitiesService
{
private fflib_ApexMocks mocks;

public OpportunitiesSelector(fflib_ApexMocks mocks)
public OpportunitiesService(fflib_ApexMocks mocks)
{
super(mocks);
this.mocks = mocks;
}

public List<Opportunity> selectByIdWithProducts(Set<ID> idSet)
public void applyDiscounts(Set<ID> opportunityIds, Decimal discountPercentage)
{
if (mocks.Verifying)
{
mocks.verifyMethodCall(this, 'selectByIdWithProducts', new List<Object> {idSet});
}
else if (mocks.Stubbing)
{
mocks.prepareMethodReturnValue(this, 'selectByIdWithProducts', new List<Object> {idSet});
return null;
}
else
{
mocks.recordMethod(this, 'selectByIdWithProducts', new List<Object> {idSet});

fflib_MethodReturnValue methodReturnValue = mocks.getMethodReturnValue(this, 'selectByIdWithProducts', new List<Object> {idSet});

if (methodReturnValue != null)
{
if (methodReturnValue.ReturnValue instanceof Exception)
{
throw ((Exception) methodReturnValue.ReturnValue);
}
mocks.mockVoidMethod(this, 'applyDiscounts', new List<Object> {opportunityIds, discountPercentage});
}

return (List<Opportunity>) methodReturnValue.ReturnValue;
}
}
public Set<Id> createInvoices(Set<ID> opportunityIds, Decimal discountPercentage)
{
return (Set<Id>) mocks.mockNonVoidMethod(this, 'createInvoices', new List<Object> {opportunityIds, discountPercentage});
}

return null;
public Id submitInvoicingJob()
{
return (Id) mocks.mockNonVoidMethod(this, 'submitInvoicingJob', new List<Object> {});
}
}
}
}
3 changes: 3 additions & 0 deletions interfacemocks.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IOpportunities=Opportunities:fflib_SObjectMocks.SObjectDomain
IOpportunitiesSelector=OpportunitiesSelector:fflib_SObjectMocks.SObjectSelector
IOpportunitiesService=OpportunitiesService

0 comments on commit 2857bd7

Please sign in to comment.