From 690729744e954421db755b1b9743711f93ed8322 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Mon, 21 Feb 2022 10:49:24 +0000 Subject: [PATCH 01/17] Added ability to pass in literals to fflib_Criteria Started work on Date Literals for use with fflib_Criteria --- .../classes/criteria/fflib_Criteria.cls | 11 ++ .../fflib-extension/ortoo_DateLiterals.cls | 160 ++++++++++++++++++ .../ortoo_DateLiterals.cls-meta.xml | 5 + 3 files changed, 176 insertions(+) create mode 100644 framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls create mode 100644 framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls-meta.xml diff --git a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls index ff4f1f58b89..63db20059e1 100755 --- a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls +++ b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls @@ -768,6 +768,11 @@ public virtual with sharing class fflib_Criteria this.embraced = embraced; } + // TODO: move - consider adding to the original library + public interface Literal { + String toLiteral(); + } + /** * @param value The value to convert * @@ -777,6 +782,12 @@ public virtual with sharing class fflib_Criteria { if (value == null) return 'null'; + // TODO: test this + if ( value instanceOf Literal ) + { + return ((Literal)value).toLiteral(); + } + if (value instanceof String || value instanceof Id) { String manipulated = (String) value; diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls new file mode 100644 index 00000000000..4243c6e8103 --- /dev/null +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -0,0 +1,160 @@ +/** + * Class that provides a list of inner classes that can be used as targets for comparisons in ortoo_Criteria. + * + * Specifically, the classes represent the different Date Literals that SOQL supports + * + * @group fflib Extension + */ +public inherited sharing class ortoo_DateLiterals +{ + // TODO: consider 'compare' - how do we do that? + private interface Literal extends fflib_Criteria.Literal {} + + public class Today implements Literal + { + public String toLiteral() + { + return 'TODAY'; + } + } + + public class Yesterday implements Literal + { + public String toLiteral() + { + return 'YESTERDAY'; + } + } + + public class LastWeek implements Literal + { + public String toLiteral() + { + return 'LAST_WEEK'; + } + } + + public class ThisWeek implements Literal + { + public String toLiteral() + { + return 'THIS_WEEK'; + } + } + + public class NextWeek implements Literal + { + public String toLiteral() + { + return 'NEXT_WEEK'; + } + } + + public class LastMonth implements Literal + { + public String toLiteral() + { + return 'LAST_MONTH'; + } + } + + public class ThisMonth implements Literal + { + public String toLiteral() + { + return 'THIS_MONTH'; + } + } + + public class NextMonth implements Literal + { + public String toLiteral() + { + return 'NEXT_MONTH'; + } + } + + public class Last90Days implements Literal + { + public String toLiteral() + { + return 'LAST_90_DAYS'; + } + } + + public class Next90Days implements Literal + { + public String toLiteral() + { + return 'NEXT_90_DAYS'; + } + } + + public class LastNDays extends NumericallyQualifiedLiteral + { + public LastNDays( Integer numberOfThings ) + { + super( numberOfThings, 'LAST_N_DAYS' ); + } + } + + public class NextNDays extends NumericallyQualifiedLiteral + { + public NextNDays( Integer numberOfThings ) + { + super( numberOfThings, 'NEXT_N_DAYS' ); + } + } + + public class LastNWeeks extends NumericallyQualifiedLiteral + { + public LastNWeeks( Integer numberOfThings ) + { + super( numberOfThings, 'LAST_N_WEEKS' ); + } + } + + public class NextNWeeks extends NumericallyQualifiedLiteral + { + public NextNWeeks( Integer numberOfThings ) + { + super( numberOfThings, 'NEXT_N_WEEKS' ); + } + } + + public class LastNMonths extends NumericallyQualifiedLiteral + { + public LastNMonths( Integer numberOfThings ) + { + super( numberOfThings, 'LAST_N_MONTHS' ); + } + } + + public class NextNMonths extends NumericallyQualifiedLiteral + { + public NextNMonths( Integer numberOfThings ) + { + super( numberOfThings, 'NEXT_N_MONTHS' ); + } + } + + private abstract class NumericallyQualifiedLiteral implements Literal + { + Integer numberOfThings; + String baseLiteral; + + protected NumericallyQualifiedLiteral( Integer numberOfThings, String baseLiteral ) + { + Contract.requires( numberOfThings != null, 'constructor called with a null numberOfThings' ); + Contract.requires( baseLiteral != null, 'constructor called with a null baseLiteral' ); + + this.numberOfThings = numberOfThings; + this.baseLiteral = baseLiteral; + } + + public String toLiteral() + { + return this.baseLiteral + ':' + this.numberOfThings; + } + } +} \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls-meta.xml b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls-meta.xml new file mode 100644 index 00000000000..dd61d1f917e --- /dev/null +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + From b858500f0016c628e85f8eeb1f1ef30ca88156ca Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Mon, 21 Feb 2022 11:22:27 +0000 Subject: [PATCH 02/17] Started playing with evaluating things against date literals --- .../classes/criteria/fflib_Criteria.cls | 4 ++ .../default/classes/FrameworkErrorCodes.cls | 12 +++--- .../fflib-extension/ortoo_DateLiterals.cls | 42 +++++++++++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls index 63db20059e1..9c7608a61f6 100755 --- a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls +++ b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls @@ -772,6 +772,10 @@ public virtual with sharing class fflib_Criteria public interface Literal { String toLiteral(); } + // TODO: move - consider adding to the original library + public interface Evaluatable { + Object toValue(); + } /** * @param value The value to convert diff --git a/framework/default/ortoo-core/default/classes/FrameworkErrorCodes.cls b/framework/default/ortoo-core/default/classes/FrameworkErrorCodes.cls index 101110e471f..26746ece8bf 100644 --- a/framework/default/ortoo-core/default/classes/FrameworkErrorCodes.cls +++ b/framework/default/ortoo-core/default/classes/FrameworkErrorCodes.cls @@ -22,11 +22,13 @@ public inherited sharing class FrameworkErrorCodes { public final static String CONFIGURATION_WITH_INVALID_CLASS = 'APP-00002'; public final static String CONFIGURATION_WITH_INVALID_SOBJECT_TYPE = 'APP-00003'; - public final static String DML_ON_INACCESSIBLE_FIELDS = '00000'; - public final static String DML_INSERT_NOT_ALLOWED = '00001'; - public final static String DML_UPDATE_NOT_ALLOWED = '00002'; - public final static String DML_DELETE_NOT_ALLOWED = '00003'; - public final static String DML_PUBLISH_NOT_ALLOWED = '00004'; + public final static String NON_EVALUATABLE_CRITERIA = 'CRI-00000'; + + public final static String DML_ON_INACCESSIBLE_FIELDS = '0000000'; + public final static String DML_INSERT_NOT_ALLOWED = '0000001'; + public final static String DML_UPDATE_NOT_ALLOWED = '0000002'; + public final static String DML_DELETE_NOT_ALLOWED = '0000003'; + public final static String DML_PUBLISH_NOT_ALLOWED = '0000004'; public final static String SELECTOR_UNBOUND_COUNT_QUERY = '0000000'; diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index 4243c6e8103..d9a832fe47b 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -7,26 +7,52 @@ */ public inherited sharing class ortoo_DateLiterals { + public class NonEvaluatableException extends ortoo_Exception {} + // TODO: consider 'compare' - how do we do that? private interface Literal extends fflib_Criteria.Literal {} + private interface Evaluatable extends fflib_Criteria.Evaluatable {} - public class Today implements Literal + public class Today implements Literal, Evaluatable { public String toLiteral() { return 'TODAY'; } + + public Date toValue() + { + return Date.today(); + } } - public class Yesterday implements Literal + public class Yesterday implements Literal, Evaluatable { public String toLiteral() { return 'YESTERDAY'; } + + public Date toValue() + { + return Date.today().addDays(-1); + } } - public class LastWeek implements Literal + public class Tomorrow implements Literal, Evaluatable + { + public String toLiteral() + { + return 'TOMORROW'; + } + + public Date toValue() + { + return Date.today().addDays(+1); + } + } + + public class LastWeek extends NonEvaluatableLiteral implements Literal { public String toLiteral() { @@ -157,4 +183,14 @@ public inherited sharing class ortoo_DateLiterals return this.baseLiteral + ':' + this.numberOfThings; } } + + private abstract class NonEvaluatableLiteral implements Evaluatable + { + public Object toValue() + { + throw new NonEvaluatableException( 'Literals of type ' + ObjectUtils.getClassName( this ) + ' cannot be evaluated in-memory' ) + .setErrorCode( FrameworkErrorCodes.NON_EVALUATABLE_CRITERIA ) + .addContext( 'ClassName', ObjectUtils.getClassName( this ) ); + } + } } \ No newline at end of file From d4d8519e6566e2a68088a6aab913b97817531e06 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Mon, 21 Feb 2022 13:40:59 +0000 Subject: [PATCH 03/17] More experiments with comparing dates Still would need work on DateTime --- .../classes/criteria/fflib_Comparator.cls | 20 ++ .../classes/criteria/fflib_Criteria.cls | 4 - .../fflib-extension/ortoo_DateLiterals.cls | 296 ++++++++++++++++-- 3 files changed, 291 insertions(+), 29 deletions(-) diff --git a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls index 368af0dcf92..2e8ae2a6cb1 100644 --- a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls +++ b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls @@ -30,6 +30,16 @@ */ public with sharing class fflib_Comparator { + // TODO: move - consider adding to the original library + public interface Evaluatable + { + Object toValue(); + } + + public interface Comparable + { + Integer compare( Object otherValue ); + } public static Boolean compareTo(Object object1, fflib_Operator operator, Object object2) { @@ -53,6 +63,16 @@ public with sharing class fflib_Comparator public static Integer compare(Object object1, Object object2) { + // TODO: test + if ( object2 instanceOf fflib_Comparator.Comparable ) { + return ((fflib_Comparator.Comparable)object2).compare( object1 ); + } + + // TODO: test + if ( object2 instanceOf Evaluatable ) { + object2 = ((Evaluatable)object2)?.toValue(); + } + if (object1 == null && object2 == null) return 0; else if (object1 == null) diff --git a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls index 9c7608a61f6..63db20059e1 100755 --- a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls +++ b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls @@ -772,10 +772,6 @@ public virtual with sharing class fflib_Criteria public interface Literal { String toLiteral(); } - // TODO: move - consider adding to the original library - public interface Evaluatable { - Object toValue(); - } /** * @param value The value to convert diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index d9a832fe47b..fd265e316a5 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -7,11 +7,113 @@ */ public inherited sharing class ortoo_DateLiterals { + // TODO: datetime behaviours too? + public class NonEvaluatableException extends ortoo_Exception {} - // TODO: consider 'compare' - how do we do that? private interface Literal extends fflib_Criteria.Literal {} - private interface Evaluatable extends fflib_Criteria.Evaluatable {} + private interface Evaluatable extends fflib_Comparator.Evaluatable {} + private interface Comparable extends fflib_Comparator.Comparable {} + + private static Date today = Date.today(); + + public static Date tomorrow + { + get { + return today.addDays( 1 ); + } + } + + public static Date yesterday + { + get { + return today.addDays( -1 ); + } + } + + public static Date startOfThisWeek + { + get { + return today.toStartOfWeek(); + } + } + + public static Date endOfThisWeek + { + get { + return startOfThisWeek.addDays( 6 ); + } + } + + public static Date startOfLastWeek + { + get { + return startOfThisWeek.addDays( -7 ); + } + } + + public static Date endOfLastWeek + { + get { + return endOfThisWeek.addDays( -7 ); + } + } + + public static Date startOfNextWeek + { + get { + return startOfThisWeek.addDays( 7 ); + } + } + + public static Date endOfNextWeek + { + get { + return endOfThisWeek.addDays( 7 ); + } + } + + public static Date startOfThisMonth + { + get { + return today.toStartOfMonth(); + } + } + + public static Date endOfThisMonth + { + get { + return startOfThisMonth.addMonths( 1 ).addDays( -1 ); + } + } + + public static Date startOfNextMonth + { + get { + return startOfThisMonth.addMonths( 1 ); + } + } + + public static Date endOfNextMonth + { + get { + return startOfThisMonth.addMonths( 1 ).addDays( -1 ); // Note, do not change to endOfThisMonth.addMonths, as this can switch months + } + } + + public static Date startOfLastMonth + { + get { + return startOfThisMonth.addMonths( -1 ); + } + } + + public static Date endOfLastMonth + { + get { + return startOfThisMonth.addDays( -1 ); // Note, do not change to endOfThisMonth.addMonths, as this can switch months + } + } public class Today implements Literal, Evaluatable { @@ -22,7 +124,7 @@ public inherited sharing class ortoo_DateLiterals public Date toValue() { - return Date.today(); + return today; } } @@ -35,7 +137,7 @@ public inherited sharing class ortoo_DateLiterals public Date toValue() { - return Date.today().addDays(-1); + return yesterday; } } @@ -48,123 +150,251 @@ public inherited sharing class ortoo_DateLiterals public Date toValue() { - return Date.today().addDays(+1); + return tomorrow; } } - public class LastWeek extends NonEvaluatableLiteral implements Literal + public class LastWeek extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'LAST_WEEK'; } + + protected override Date getStartDate() { + return startOfLastWeek; + } + + protected override Date getEndDate() { + return endOfLastWeek; + } } - public class ThisWeek implements Literal + public class ThisWeek extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'THIS_WEEK'; } + + protected override Date getStartDate() { + return startOfThisWeek; + } + + protected override Date getEndDate() { + return endOfThisWeek; + } } - public class NextWeek implements Literal + public class NextWeek extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'NEXT_WEEK'; } + + protected override Date getStartDate() { + return startOfNextWeek; + } + + protected override Date getEndDate() { + return endOfNextWeek; + } } - public class LastMonth implements Literal + public class LastMonth extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'LAST_MONTH'; } + + protected override Date getStartDate() { + return startOfLastMonth; + } + + protected override Date getEndDate() { + return endOfLastMonth; + } } - public class ThisMonth implements Literal + public class ThisMonth extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'THIS_MONTH'; } + + protected override Date getStartDate() { + return startOfThisMonth; + } + + protected override Date getEndDate() { + return endOfThisMonth; + } } - public class NextMonth implements Literal + public class NextMonth extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'NEXT_MONTH'; } + + protected override Date getStartDate() { + return startOfNextMonth; + } + + protected override Date getEndDate() { + return endOfNextMonth; + } } - public class Last90Days implements Literal + public class Last90Days extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'LAST_90_DAYS'; } + + protected override Date getStartDate() { + return today.addDays( -90 ); + } + + protected override Date getEndDate() { + return today; + } } - public class Next90Days implements Literal + public class Next90Days extends DateRangeLiteral implements Literal, Comparable { public String toLiteral() { return 'NEXT_90_DAYS'; } + + protected override Date getStartDate() { + return tomorrow; + } + + protected override Date getEndDate() { + return today.addDays( 90 ); // TODO: not true + } } - public class LastNDays extends NumericallyQualifiedLiteral + public class LastNDays extends NumericallyQualifiedLiteral implements Literal, Comparable { public LastNDays( Integer numberOfThings ) { super( numberOfThings, 'LAST_N_DAYS' ); + + Contract.requires( numberOfThings != null, 'LastNDays constructed with a null number of days' ); + Contract.requires( numberOfThings > 0 , 'LastNDays constructed with a negative or zero number of days' ); + } + + protected override Date getStartDate() { + return today.addDays( numberOfThings * -1 ); + } + + protected override Date getEndDate() { + return today; } } - public class NextNDays extends NumericallyQualifiedLiteral + public class NextNDays extends NumericallyQualifiedLiteral implements Literal, Comparable { public NextNDays( Integer numberOfThings ) { super( numberOfThings, 'NEXT_N_DAYS' ); + + Contract.requires( numberOfThings != null, 'NextNDays constructed with a null number of days' ); + Contract.requires( numberOfThings > 0 , 'NextNDays constructed with a negative or zero number of days' ); + } + + protected override Date getStartDate() { + return tomorrow; + } + + protected override Date getEndDate() { + return today.addDays( numberOfThings ); } } - public class LastNWeeks extends NumericallyQualifiedLiteral + public class LastNWeeks extends NumericallyQualifiedLiteral implements Literal, Comparable { public LastNWeeks( Integer numberOfThings ) { super( numberOfThings, 'LAST_N_WEEKS' ); + + Contract.requires( numberOfThings != null, 'LastNWeeks constructed with a null number of days' ); + Contract.requires( numberOfThings > 0 , 'LastNWeeks constructed with a negative or zero number of days' ); + } + + protected override Date getStartDate() { + return startOfThisWeek.addDays( this.numberOfThings * -7 ); + } + + protected override Date getEndDate() { + return endOfLastWeek; } } - public class NextNWeeks extends NumericallyQualifiedLiteral + public class NextNWeeks extends NumericallyQualifiedLiteral implements Literal, Comparable { public NextNWeeks( Integer numberOfThings ) { super( numberOfThings, 'NEXT_N_WEEKS' ); } + + protected override Date getStartDate() { + return startOfNextWeek; + } + + protected override Date getEndDate() { + return endOfNextWeek.addDays( this.numberOfThings * 7 ); + } } - public class LastNMonths extends NumericallyQualifiedLiteral + public class LastNMonths extends NumericallyQualifiedLiteral implements Literal, Comparable { public LastNMonths( Integer numberOfThings ) { super( numberOfThings, 'LAST_N_MONTHS' ); + + Contract.requires( numberOfThings != null, 'LastNMonths constructed with a null number of months' ); + Contract.requires( numberOfThings > 0 , 'LastNMonths constructed with a negative or zero number of months' ); + } + + protected override Date getStartDate() { + return endOfLastMonth; + } + + protected override Date getEndDate() { + return startOfThisMonth.addMonths( numberOfThings * -1 ); } } - public class NextNMonths extends NumericallyQualifiedLiteral + public class NextNMonths extends NumericallyQualifiedLiteral implements Literal, Comparable { public NextNMonths( Integer numberOfThings ) { super( numberOfThings, 'NEXT_N_MONTHS' ); + + Contract.requires( numberOfThings != null, 'NextNMonths constructed with a null number of months' ); + Contract.requires( numberOfThings > 0 , 'NextNMonths constructed with a negative or zero number of months' ); + + } + + protected override Date getStartDate() { + return startOfNextMonth; + } + + protected override Date getEndDate() { + return startOfNextMonth.addMonths( numberOfThings ).addDays( -1 ); } } - private abstract class NumericallyQualifiedLiteral implements Literal + private abstract class NumericallyQualifiedLiteral extends DateRangeLiteral implements Literal { Integer numberOfThings; String baseLiteral; @@ -184,13 +414,29 @@ public inherited sharing class ortoo_DateLiterals } } - private abstract class NonEvaluatableLiteral implements Evaluatable + private abstract class DateRangeLiteral implements ortoo_DateLiterals.Comparable { - public Object toValue() + protected abstract Date getStartDate(); + protected abstract Date getEndDate(); + + public Integer compare( Object otherValue ) { - throw new NonEvaluatableException( 'Literals of type ' + ObjectUtils.getClassName( this ) + ' cannot be evaluated in-memory' ) - .setErrorCode( FrameworkErrorCodes.NON_EVALUATABLE_CRITERIA ) - .addContext( 'ClassName', ObjectUtils.getClassName( this ) ); + return new DateRangeComparer().compare( (Date)otherValue, getStartDate(), getEndDate() ); + } + } + + private class DateRangeComparer + { + public Integer compare( Date value, Date startDate, Date endDate ) { + if ( value < startDate ) + { + return -1; + } + if ( value > endDate ) + { + return 1; + } + return 0; } } } \ No newline at end of file From 9323e955f00b1dbdda02de04468120563e227c9f Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Tue, 22 Feb 2022 09:05:06 +0000 Subject: [PATCH 04/17] Removed defunct 'evaluator' Added docs to the public member variables and classes --- .../classes/criteria/fflib_Comparator.cls | 14 +- .../fflib-extension/ortoo_DateLiterals.cls | 192 +++++++++++++++--- 2 files changed, 165 insertions(+), 41 deletions(-) diff --git a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls index 2e8ae2a6cb1..2f462c78d47 100644 --- a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls +++ b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls @@ -30,11 +30,6 @@ */ public with sharing class fflib_Comparator { - // TODO: move - consider adding to the original library - public interface Evaluatable - { - Object toValue(); - } public interface Comparable { @@ -64,13 +59,8 @@ public with sharing class fflib_Comparator public static Integer compare(Object object1, Object object2) { // TODO: test - if ( object2 instanceOf fflib_Comparator.Comparable ) { - return ((fflib_Comparator.Comparable)object2).compare( object1 ); - } - - // TODO: test - if ( object2 instanceOf Evaluatable ) { - object2 = ((Evaluatable)object2)?.toValue(); + if ( object2 instanceOf Comparable ) { + return ((Comparable)object2).compare( object1 ); } if (object1 == null && object2 == null) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index fd265e316a5..0f41bbdb1fe 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -1,22 +1,29 @@ /** - * Class that provides a list of inner classes that can be used as targets for comparisons in ortoo_Criteria. + * Class that provides: * - * Specifically, the classes represent the different Date Literals that SOQL supports + * * Shorthands for specific dates related to today. + * E.g. today, yesterday, tomorrow, startOfLastWeek + * + * * A list of inner classes that can be used as targets for comparisons in ortoo_Criteria. + * Specifically, the classes represent a subset of the Date Literals that SOQL supports + * + * * Note that if the date shorthands are used, then their behaviour can be overridden in tests + * by changing the value of 'today'. * * @group fflib Extension */ public inherited sharing class ortoo_DateLiterals { - // TODO: datetime behaviours too? - public class NonEvaluatableException extends ortoo_Exception {} private interface Literal extends fflib_Criteria.Literal {} - private interface Evaluatable extends fflib_Comparator.Evaluatable {} private interface Comparable extends fflib_Comparator.Comparable {} - private static Date today = Date.today(); + public static Date today = Date.today(); + /** + * Dynamic representation of the date 'tomorrow', based on the same class's representation of 'today' + */ public static Date tomorrow { get { @@ -24,6 +31,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'yesterday', based on the same class's representation of 'today' + */ public static Date yesterday { get { @@ -31,6 +41,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'start of this week', based on the same class's representation of 'today' + */ public static Date startOfThisWeek { get { @@ -38,6 +51,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'end of this week', based on the same class's representation of 'today' + */ public static Date endOfThisWeek { get { @@ -45,6 +61,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'start of last week', based on the same class's representation of 'today' + */ public static Date startOfLastWeek { get { @@ -52,6 +71,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'end of last week', based on the same class's representation of 'today' + */ public static Date endOfLastWeek { get { @@ -59,6 +81,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'start of next week', based on the same class's representation of 'today' + */ public static Date startOfNextWeek { get { @@ -66,6 +91,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'end of next week', based on the same class's representation of 'today' + */ public static Date endOfNextWeek { get { @@ -73,6 +101,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'start of this month', based on the same class's representation of 'today' + */ public static Date startOfThisMonth { get { @@ -80,6 +111,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'end of this month', based on the same class's representation of 'today' + */ public static Date endOfThisMonth { get { @@ -87,6 +121,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'start of next month', based on the same class's representation of 'today' + */ public static Date startOfNextMonth { get { @@ -94,6 +131,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'end of next month', based on the same class's representation of 'today' + */ public static Date endOfNextMonth { get { @@ -101,6 +141,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'start of last month', based on the same class's representation of 'today' + */ public static Date startOfLastMonth { get { @@ -108,6 +151,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * Dynamic representation of the date 'end of last month', based on the same class's representation of 'today' + */ public static Date endOfLastMonth { get { @@ -115,48 +161,69 @@ public inherited sharing class ortoo_DateLiterals } } - public class Today implements Literal, Evaluatable + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'TODAY' + */ + public class Today extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'TODAY'; } - public Date toValue() - { + protected override Date getStartDate() { + return today; + } + + protected override Date getEndDate() { return today; } } - public class Yesterday implements Literal, Evaluatable + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'YESTERDAY' + */ + public class Yesterday extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'YESTERDAY'; } - public Date toValue() - { + protected override Date getStartDate() { + return yesterday; + } + + protected override Date getEndDate() { return yesterday; } } - public class Tomorrow implements Literal, Evaluatable + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'TOMORROW' + */ + public class Tomorrow extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'TOMORROW'; } - public Date toValue() - { + protected override Date getStartDate() { + return tomorrow; + } + + protected override Date getEndDate() { return tomorrow; } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'LAST_WEEK' + */ public class LastWeek extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'LAST_WEEK'; } @@ -170,9 +237,12 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'THIS_WEEK' + */ public class ThisWeek extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'THIS_WEEK'; } @@ -186,9 +256,12 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'NEXT_WEEK' + */ public class NextWeek extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'NEXT_WEEK'; } @@ -202,9 +275,12 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'LAST_MONTH' + */ public class LastMonth extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'LAST_MONTH'; } @@ -218,9 +294,12 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'THIS_MONTH' + */ public class ThisMonth extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'THIS_MONTH'; } @@ -234,9 +313,12 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'NEXT_MONTH' + */ public class NextMonth extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'NEXT_MONTH'; } @@ -250,9 +332,12 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'LAST_90_DAYS' + */ public class Last90Days extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'LAST_90_DAYS'; } @@ -266,9 +351,12 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'NEXT_90_DAYS' + */ public class Next90Days extends DateRangeLiteral implements Literal, Comparable { - public String toLiteral() + public override String toLiteral() { return 'NEXT_90_DAYS'; } @@ -282,6 +370,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'LAST_N_DAYS' + */ public class LastNDays extends NumericallyQualifiedLiteral implements Literal, Comparable { public LastNDays( Integer numberOfThings ) @@ -301,6 +392,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'NEXT_N_DAYS' + */ public class NextNDays extends NumericallyQualifiedLiteral implements Literal, Comparable { public NextNDays( Integer numberOfThings ) @@ -320,6 +414,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'LAST_N_WEEKS' + */ public class LastNWeeks extends NumericallyQualifiedLiteral implements Literal, Comparable { public LastNWeeks( Integer numberOfThings ) @@ -339,6 +436,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'NEXT_N_WEEKS' + */ public class NextNWeeks extends NumericallyQualifiedLiteral implements Literal, Comparable { public NextNWeeks( Integer numberOfThings ) @@ -355,6 +455,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'LAST_N_MONTHS' + */ public class LastNMonths extends NumericallyQualifiedLiteral implements Literal, Comparable { public LastNMonths( Integer numberOfThings ) @@ -374,6 +477,9 @@ public inherited sharing class ortoo_DateLiterals } } + /** + * ortoo_Criteria compatible literal that represents the SOQL Date Literal 'NEXT_N_MONTHS' + */ public class NextNMonths extends NumericallyQualifiedLiteral implements Literal, Comparable { public NextNMonths( Integer numberOfThings ) @@ -408,7 +514,7 @@ public inherited sharing class ortoo_DateLiterals this.baseLiteral = baseLiteral; } - public String toLiteral() + public override String toLiteral() { return this.baseLiteral + ':' + this.numberOfThings; } @@ -416,16 +522,44 @@ public inherited sharing class ortoo_DateLiterals private abstract class DateRangeLiteral implements ortoo_DateLiterals.Comparable { + protected abstract String toLiteral(); protected abstract Date getStartDate(); protected abstract Date getEndDate(); public Integer compare( Object otherValue ) { - return new DateRangeComparer().compare( (Date)otherValue, getStartDate(), getEndDate() ); + if ( otherValue instanceOf Date ) + { + return new DateToDateRangeComparer().compare( (Date)otherValue, getStartDate(), getEndDate() ); + } + if ( otherValue instanceOf DateTime ) + { + return new DateTimeToDateRangeComparer().compare( (DateTime)otherValue, getStartDate(), getEndDate() ); + } + + throw new NonEvaluatableException( 'Attempted to compare a non Date / DateTime with a Date Literal' ) + .setErrorCode( FrameworkErrorCodes.NON_EVALUATABLE_CRITERIA ) + .addContext( 'DateLiteral', toLiteral() ); + } + } + + private class DateTimeToDateRangeComparer + { + public Integer compare( DateTime value, Date startDate, Date endDate ) { + + if ( value < DateTime.newInstance( startDate.year(), startDate.month(), startDate.day(), 0, 0, 0 ) ) + { + return -1; + } + if ( value > DateTime.newInstance( endDate.year(), endDate.month(), endDate.day(), 23, 59, 29 ) ) + { + return 1; + } + return 0; } } - private class DateRangeComparer + private class DateToDateRangeComparer { public Integer compare( Date value, Date startDate, Date endDate ) { if ( value < startDate ) From e49e2bc424b5580a285cd33a7b193c93d1b6f4fc Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 11:21:22 +0000 Subject: [PATCH 05/17] Formatting updated to standards --- .../fflib-extension/ortoo_DateLiterals.cls | 146 ++++++++++++------ 1 file changed, 97 insertions(+), 49 deletions(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index 0f41bbdb1fe..94f99867d38 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -26,7 +26,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date tomorrow { - get { + get + { return today.addDays( 1 ); } } @@ -36,7 +37,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date yesterday { - get { + get + { return today.addDays( -1 ); } } @@ -46,7 +48,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date startOfThisWeek { - get { + get + { return today.toStartOfWeek(); } } @@ -56,7 +59,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date endOfThisWeek { - get { + get + { return startOfThisWeek.addDays( 6 ); } } @@ -66,7 +70,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date startOfLastWeek { - get { + get + { return startOfThisWeek.addDays( -7 ); } } @@ -76,7 +81,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date endOfLastWeek { - get { + get + { return endOfThisWeek.addDays( -7 ); } } @@ -86,7 +92,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date startOfNextWeek { - get { + get + { return startOfThisWeek.addDays( 7 ); } } @@ -96,7 +103,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date endOfNextWeek { - get { + get + { return endOfThisWeek.addDays( 7 ); } } @@ -106,7 +114,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date startOfThisMonth { - get { + get + { return today.toStartOfMonth(); } } @@ -116,7 +125,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date endOfThisMonth { - get { + get + { return startOfThisMonth.addMonths( 1 ).addDays( -1 ); } } @@ -126,7 +136,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date startOfNextMonth { - get { + get + { return startOfThisMonth.addMonths( 1 ); } } @@ -136,7 +147,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date endOfNextMonth { - get { + get + { return startOfThisMonth.addMonths( 1 ).addDays( -1 ); // Note, do not change to endOfThisMonth.addMonths, as this can switch months } } @@ -146,7 +158,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date startOfLastMonth { - get { + get + { return startOfThisMonth.addMonths( -1 ); } } @@ -156,7 +169,8 @@ public inherited sharing class ortoo_DateLiterals */ public static Date endOfLastMonth { - get { + get + { return startOfThisMonth.addDays( -1 ); // Note, do not change to endOfThisMonth.addMonths, as this can switch months } } @@ -171,11 +185,13 @@ public inherited sharing class ortoo_DateLiterals return 'TODAY'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return today; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return today; } } @@ -190,11 +206,13 @@ public inherited sharing class ortoo_DateLiterals return 'YESTERDAY'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return yesterday; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return yesterday; } } @@ -209,11 +227,13 @@ public inherited sharing class ortoo_DateLiterals return 'TOMORROW'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return tomorrow; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return tomorrow; } } @@ -228,11 +248,13 @@ public inherited sharing class ortoo_DateLiterals return 'LAST_WEEK'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfLastWeek; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfLastWeek; } } @@ -247,11 +269,13 @@ public inherited sharing class ortoo_DateLiterals return 'THIS_WEEK'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfThisWeek; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfThisWeek; } } @@ -266,11 +290,13 @@ public inherited sharing class ortoo_DateLiterals return 'NEXT_WEEK'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfNextWeek; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfNextWeek; } } @@ -285,11 +311,13 @@ public inherited sharing class ortoo_DateLiterals return 'LAST_MONTH'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfLastMonth; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfLastMonth; } } @@ -304,11 +332,13 @@ public inherited sharing class ortoo_DateLiterals return 'THIS_MONTH'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfThisMonth; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfThisMonth; } } @@ -323,11 +353,13 @@ public inherited sharing class ortoo_DateLiterals return 'NEXT_MONTH'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfNextMonth; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfNextMonth; } } @@ -342,11 +374,13 @@ public inherited sharing class ortoo_DateLiterals return 'LAST_90_DAYS'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return today.addDays( -90 ); } - protected override Date getEndDate() { + protected override Date getEndDate() + { return today; } } @@ -361,12 +395,14 @@ public inherited sharing class ortoo_DateLiterals return 'NEXT_90_DAYS'; } - protected override Date getStartDate() { + protected override Date getStartDate() + { return tomorrow; } - protected override Date getEndDate() { - return today.addDays( 90 ); // TODO: not true + protected override Date getEndDate() + { + return today.addDays( 90 ); } } @@ -383,11 +419,13 @@ public inherited sharing class ortoo_DateLiterals Contract.requires( numberOfThings > 0 , 'LastNDays constructed with a negative or zero number of days' ); } - protected override Date getStartDate() { + protected override Date getStartDate() + { return today.addDays( numberOfThings * -1 ); } - protected override Date getEndDate() { + protected override Date getEndDate() + { return today; } } @@ -405,11 +443,13 @@ public inherited sharing class ortoo_DateLiterals Contract.requires( numberOfThings > 0 , 'NextNDays constructed with a negative or zero number of days' ); } - protected override Date getStartDate() { + protected override Date getStartDate() + { return tomorrow; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return today.addDays( numberOfThings ); } } @@ -427,11 +467,13 @@ public inherited sharing class ortoo_DateLiterals Contract.requires( numberOfThings > 0 , 'LastNWeeks constructed with a negative or zero number of days' ); } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfThisWeek.addDays( this.numberOfThings * -7 ); } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfLastWeek; } } @@ -446,11 +488,13 @@ public inherited sharing class ortoo_DateLiterals super( numberOfThings, 'NEXT_N_WEEKS' ); } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfNextWeek; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return endOfNextWeek.addDays( this.numberOfThings * 7 ); } } @@ -468,11 +512,13 @@ public inherited sharing class ortoo_DateLiterals Contract.requires( numberOfThings > 0 , 'LastNMonths constructed with a negative or zero number of months' ); } - protected override Date getStartDate() { + protected override Date getStartDate() + { return endOfLastMonth; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return startOfThisMonth.addMonths( numberOfThings * -1 ); } } @@ -491,11 +537,13 @@ public inherited sharing class ortoo_DateLiterals } - protected override Date getStartDate() { + protected override Date getStartDate() + { return startOfNextMonth; } - protected override Date getEndDate() { + protected override Date getEndDate() + { return startOfNextMonth.addMonths( numberOfThings ).addDays( -1 ); } } From 8849cc89281be1c26b08fc1b0e39f17def4bfddd Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 12:13:49 +0000 Subject: [PATCH 06/17] Added ortoo_Asserts and moved all Amoss_Asserts calls over to ortoo --- .../exceptions/tests/ortoo_ExceptionTest.cls | 38 +++--- .../fflib-extension/tests/SecureDmlTest.cls | 20 +-- .../tests/ortoo_AppLogicFactoryTest.cls | 4 +- .../ortoo_ChildRecordFinderFactoryTest.cls | 8 +- .../tests/ortoo_CriteriaTest.cls | 38 +++--- .../tests/ortoo_DomainFactoryTest.cls | 2 +- .../ortoo_DynamicSobjectSelectorTest.cls | 12 +- .../ortoo_MessageRendererFactoryTest.cls | 10 +- .../tests/ortoo_SelectorFactoryTest.cls | 2 +- .../tests/ortoo_ServiceFactoryTest.cls | 2 +- .../tests/ortoo_SimpleObjectFactoryTest.cls | 14 +- .../tests/ortoo_SobjectDomainTest.cls | 2 +- .../tests/ortoo_SobjectSelectorTest.cls | 10 +- .../ortoo_SobjectValidatorFactoryTest.cls | 18 +-- .../tests/MessageDetailTest.cls | 2 +- .../tests/MessageRendererEngineTest.cls | 6 +- .../search/tests/SearchConfigurationTest.cls | 14 +- .../search/tests/SearchControllerTest.cls | 14 +- .../search/tests/SearchOrderByTest.cls | 10 +- .../search/tests/SearchResultsTest.cls | 8 +- .../classes/search/tests/SearchWindowTest.cls | 22 +-- .../dml/tests/DmlChildContextTest.cls | 12 +- .../tests/DmlChildrenToDeleteRegisterTest.cls | 6 +- .../dml/tests/DmlDefinerOptionsTest.cls | 2 +- .../services/dml/tests/DmlDefinerTest.cls | 8 +- .../services/dml/tests/DmlRecordTest.cls | 54 ++++---- .../tests/SearchServiceImplTest.cls | 10 +- .../classes/test-utils/ortoo_Asserts.cls | 126 ++++++++++++++++++ .../test-utils/ortoo_Asserts.cls-meta.xml | 5 + .../default/classes/tests/ApplicationTest.cls | 6 +- .../classes/tests/ProcessDeactivationTest.cls | 2 +- .../classes/utils/tests/ContractTest.cls | 6 +- .../classes/utils/tests/DirectedGraphTest.cls | 6 +- .../classes/utils/tests/ListUtilsTest.cls | 14 +- .../classes/utils/tests/MapUtilsTest.cls | 2 +- .../classes/utils/tests/PackageUtilsTest.cls | 2 +- .../utils/tests/PrivateObjectUtilsTest.cls | 10 +- .../utils/tests/PublicObjectUtilsTest.cls | 10 +- .../utils/tests/SelectOptionListUtilsTest.cls | 2 +- .../classes/utils/tests/SobjectUtilsTest.cls | 22 +-- .../classes/utils/tests/StringUtilsTest.cls | 14 +- .../classes/utils/tests/UriUtilsTest.cls | 6 +- .../tests/SobjectListValidatorTest.cls | 2 +- .../validators/tests/SobjectValidatorTest.cls | 2 +- ...AbstractRedirectToLwcTabControllerTest.cls | 4 +- 45 files changed, 360 insertions(+), 229 deletions(-) create mode 100644 framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls create mode 100644 framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls-meta.xml diff --git a/framework/default/ortoo-core/default/classes/exceptions/tests/ortoo_ExceptionTest.cls b/framework/default/ortoo-core/default/classes/exceptions/tests/ortoo_ExceptionTest.cls index da557620d1d..aca703d3b52 100644 --- a/framework/default/ortoo-core/default/classes/exceptions/tests/ortoo_ExceptionTest.cls +++ b/framework/default/ortoo-core/default/classes/exceptions/tests/ortoo_ExceptionTest.cls @@ -53,8 +53,8 @@ public with sharing class ortoo_ExceptionTest { } Test.stopTest(); - Amoss_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, will return the Stack Trace based on where the exception was constructed (but not the exception constructor)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_willReturnTheStackTrace', stackTrace, 'getStackTraceString, will return the Stack Trace based on where the exception was constructed' ); + ortoo_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, will return the Stack Trace based on where the exception was constructed (but not the exception constructor)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_willReturnTheStackTrace', stackTrace, 'getStackTraceString, will return the Stack Trace based on where the exception was constructed' ); } @isTest @@ -72,8 +72,8 @@ public with sharing class ortoo_ExceptionTest { } Test.stopTest(); - Amoss_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, when the exception is subclassed, will return the Stack Trace based on where the exception was constructed (but not the exception constructor)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_whenSubclassed_willReturnTheStackTrace', stackTrace, 'getStackTraceString, when the exception is subclassed, will return the Stack Trace based on where the exception was constructed' ); + ortoo_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, when the exception is subclassed, will return the Stack Trace based on where the exception was constructed (but not the exception constructor)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_whenSubclassed_willReturnTheStackTrace', stackTrace, 'getStackTraceString, when the exception is subclassed, will return the Stack Trace based on where the exception was constructed' ); } @isTest @@ -91,10 +91,10 @@ public with sharing class ortoo_ExceptionTest { } Test.stopTest(); - Amoss_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (not the exception constructor)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.throwAnOrtooExceptionInnerMethodCall', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 1)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.throwAnOrtooException', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 2)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_whenBuiltInsideLayers_willReturnTheStackTrace', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 3)' ); + ortoo_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (not the exception constructor)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.throwAnOrtooExceptionInnerMethodCall', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 1)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.throwAnOrtooException', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 2)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_whenBuiltInsideLayers_willReturnTheStackTrace', stackTrace, 'getStackTraceString, when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 3)' ); } @isTest @@ -112,10 +112,10 @@ public with sharing class ortoo_ExceptionTest { } Test.stopTest(); - Amoss_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, when the exception is subclassed and there are multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (not the exception constructor)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.throwASubclassedExceptionInnerMethodCall', stackTrace, 'getStackTraceString, when the exception is subclassed and there are multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 1)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.throwASubclassedException', stackTrace, 'getStackTraceString, when the exception is subclassed and when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 2)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_whenSubclassedAndMultipleMethods_willReturnTheStackTrace', stackTrace, 'getStackTraceString, when the exception is subclassed and there are multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 3)' ); + ortoo_Asserts.assertDoesNotContain( '', stackTrace, 'getStackTraceString, when the exception is subclassed and there are multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (not the exception constructor)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.throwASubclassedExceptionInnerMethodCall', stackTrace, 'getStackTraceString, when the exception is subclassed and there are multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 1)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.throwASubclassedException', stackTrace, 'getStackTraceString, when the exception is subclassed and when construction is inside multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 2)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.getStackTraceString_whenSubclassedAndMultipleMethods_willReturnTheStackTrace', stackTrace, 'getStackTraceString, when the exception is subclassed and there are multiple layers of methods, will return the Stack Trace based on where the exception was raised - with each level (method 3)' ); } @isTest @@ -134,10 +134,10 @@ public with sharing class ortoo_ExceptionTest { } Test.stopTest(); - Amoss_Asserts.assertDoesNotContain( '', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point' ); - Amoss_Asserts.assertDoesNotContain( 'ortoo_ExceptionTest.throwASubclassedExceptionInnerMethodCall', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point (method 1)' ); - Amoss_Asserts.assertDoesNotContain( 'ortoo_ExceptionTest.throwASubclassedException', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point (method 2)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.regenerateStackTraceString_willCreateANewStackTraceFromTheGivenPoint', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point (actual spot called)' ); + ortoo_Asserts.assertDoesNotContain( '', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point' ); + ortoo_Asserts.assertDoesNotContain( 'ortoo_ExceptionTest.throwASubclassedExceptionInnerMethodCall', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point (method 1)' ); + ortoo_Asserts.assertDoesNotContain( 'ortoo_ExceptionTest.throwASubclassedException', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point (method 2)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.regenerateStackTraceString_willCreateANewStackTraceFromTheGivenPoint', stackTrace, 'regenerateStackTraceString, when called, will create a new stack trace from the given point (actual spot called)' ); } @isTest @@ -157,9 +157,9 @@ public with sharing class ortoo_ExceptionTest { } Test.stopTest(); - Amoss_Asserts.assertDoesNotContain( 'ortoo_ExceptionTest.throwASubclassedExceptionInnerMethodCall', stackTrace, 'regenerateStackTraceString, when called with a number of levels to skipp, will create a new stack trace from the given point, skipping the specified number of levels (1st level is skipped)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.throwASubclassedException', stackTrace, 'regenerateStackTraceString, when called with a number of levels to skipp, will create a new stack trace from the given point, skipping the specified number of levels (2nd level is not skipped)' ); - Amoss_Asserts.assertContains( 'ortoo_ExceptionTest.regenerateStackTraceString_whenPassedANumber_willCreateANewStackTraceWithLevelsSkipped', stackTrace, 'regenerateStackTraceString, when called with a number of levels to skipp, will create a new stack trace from the given point, skipping the specified number of levels (3rd level is not skipped)' ); + ortoo_Asserts.assertDoesNotContain( 'ortoo_ExceptionTest.throwASubclassedExceptionInnerMethodCall', stackTrace, 'regenerateStackTraceString, when called with a number of levels to skipp, will create a new stack trace from the given point, skipping the specified number of levels (1st level is skipped)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.throwASubclassedException', stackTrace, 'regenerateStackTraceString, when called with a number of levels to skipp, will create a new stack trace from the given point, skipping the specified number of levels (2nd level is not skipped)' ); + ortoo_Asserts.assertContains( 'ortoo_ExceptionTest.regenerateStackTraceString_whenPassedANumber_willCreateANewStackTraceWithLevelsSkipped', stackTrace, 'regenerateStackTraceString, when called with a number of levels to skipp, will create a new stack trace from the given point, skipping the specified number of levels (3rd level is not skipped)' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/SecureDmlTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/SecureDmlTest.cls index 94bdf85596c..c2c890d2266 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/SecureDmlTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/SecureDmlTest.cls @@ -258,7 +258,7 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS, will throw an exception' ); + ortoo_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS, will throw an exception' ); ortoo_Exception.Contexts contexts = thrownException.getContexts(); ortoo_Exception.Context context; @@ -423,7 +423,7 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and FLS switched off for a different object, will throw an exception' ); + ortoo_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and FLS switched off for a different object, will throw an exception' ); } @isTest @@ -462,7 +462,7 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and FLS switched off for a different field, will throw an exception' ); + ortoo_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and FLS switched off for a different field, will throw an exception' ); } @isTest @@ -501,8 +501,8 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Name', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and not all fields are switched off, will throw an exception naming the fields in violation' ); - Amoss_Asserts.assertDoesNotContain( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and not all fields are switched off, will throw an exception, not naming the fields that are supressed' ); + ortoo_Asserts.assertContains( 'Name', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and not all fields are switched off, will throw an exception naming the fields in violation' ); + ortoo_Asserts.assertDoesNotContain( 'NumberOfEmployees', thrownException.getMessage(), 'dmlInsert, when the user cannot create records because of FLS and not all fields are switched off, will throw an exception, not naming the fields that are supressed' ); ortoo_Exception.Contexts contexts = thrownException.getContexts(); ortoo_Exception.Context context; @@ -807,7 +807,7 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS, will throw an exception' ); + ortoo_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS, will throw an exception' ); ortoo_Exception.Contexts contexts = thrownException.getContexts(); ortoo_Exception.Context context; @@ -970,7 +970,7 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and FLS switched off for a different object, will throw an exception' ); + ortoo_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and FLS switched off for a different object, will throw an exception' ); } @isTest @@ -1009,7 +1009,7 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and FLS switched off for a different field, will throw an exception' ); + ortoo_Asserts.assertContains( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and FLS switched off for a different field, will throw an exception' ); } @isTest @@ -1048,8 +1048,8 @@ private without sharing class SecureDmlTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Name', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and not all fields are switched off, will throw an exception naming the fields in violation' ); - Amoss_Asserts.assertDoesNotContain( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and not all fields are switched off, will throw an exception, not naming the fields that are supressed' ); + ortoo_Asserts.assertContains( 'Name', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and not all fields are switched off, will throw an exception naming the fields in violation' ); + ortoo_Asserts.assertDoesNotContain( 'NumberOfEmployees', thrownException.getMessage(), 'dmlUpdate, when the user cannot update records because of FLS and not all fields are switched off, will throw an exception, not naming the fields that are supressed' ); ortoo_Exception.Contexts contexts = thrownException.getContexts(); ortoo_Exception.Context context; diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_AppLogicFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_AppLogicFactoryTest.cls index f046735925f..be2f4b22499 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_AppLogicFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_AppLogicFactoryTest.cls @@ -64,7 +64,7 @@ private without sharing class ortoo_AppLogicFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); } @isTest @@ -82,7 +82,7 @@ private without sharing class ortoo_AppLogicFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_AppLogicFactory instantiated with a null appLogicPerType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_AppLogicFactory instantiated with a null appLogicPerType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); } private without sharing class RegisterableType diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ChildRecordFinderFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ChildRecordFinderFactoryTest.cls index e910dd99b27..8135bb83632 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ChildRecordFinderFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ChildRecordFinderFactoryTest.cls @@ -64,7 +64,7 @@ private without sharing class ortoo_ChildRecordFinderFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ChildRecordFinderFactoryTest.NonRegisterableType does not implement IChildRecordFinder', exceptionMessage, 'newInstance, when called for an unmapped type that does not implement IChildRecordFinder, will throw an exception' ); + ortoo_Asserts.assertContains( 'ChildRecordFinderFactoryTest.NonRegisterableType does not implement IChildRecordFinder', exceptionMessage, 'newInstance, when called for an unmapped type that does not implement IChildRecordFinder, will throw an exception' ); } @isTest @@ -89,7 +89,7 @@ private without sharing class ortoo_ChildRecordFinderFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Object does not implement IChildRecordFinder', exceptionMessage, 'newInstance, when called for a mapped type that does not implement IChildRecordFinder, will throw an exception' ); + ortoo_Asserts.assertContains( 'Object does not implement IChildRecordFinder', exceptionMessage, 'newInstance, when called for a mapped type that does not implement IChildRecordFinder, will throw an exception' ); } @isTest @@ -109,7 +109,7 @@ private without sharing class ortoo_ChildRecordFinderFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); } @isTest @@ -127,7 +127,7 @@ private without sharing class ortoo_ChildRecordFinderFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_ChildRecordFinderFactory instantiated with a null childRecordFinderPerType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_ChildRecordFinderFactory instantiated with a null childRecordFinderPerType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); } private without sharing class RegisterableType implements IChildRecordFinder diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_CriteriaTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_CriteriaTest.cls index 893a3afa3c9..15ca978aee8 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_CriteriaTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_CriteriaTest.cls @@ -153,7 +153,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Expected a formula expression with number: 3', exceptionMessage, 'formulaCriteria, when given a formula and fewer criteria than referenced, will throw an exception' ); + ortoo_Asserts.assertContains( 'Expected a formula expression with number: 3', exceptionMessage, 'formulaCriteria, when given a formula and fewer criteria than referenced, will throw an exception' ); } @isTest @@ -608,7 +608,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Strings, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Strings, will throw an exception' ); } @isTest @@ -642,7 +642,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string name and an empty set of Strings, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string name and an empty set of Strings, will throw an exception' ); } @isTest @@ -676,7 +676,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Strings, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Strings, will throw an exception' ); } @isTest @@ -710,7 +710,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string name and an empty set of Longs, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string name and an empty set of Longs, will throw an exception' ); } @isTest @@ -744,7 +744,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Integers, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Integers, will throw an exception' ); } @isTest @@ -778,7 +778,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Integers, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Integers, will throw an exception' ); } @isTest @@ -815,7 +815,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Ids, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Ids, will throw an exception' ); } @isTest @@ -852,7 +852,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string name and an empty set of Ids, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string name and an empty set of Ids, will throw an exception' ); } @isTest @@ -886,7 +886,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Doubles, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Doubles, will throw an exception' ); } @isTest private static void inSet_stringName_doubleValues_whenCalled_addsAnInToTheGeneratedSoql() // NOPMD: Test method name format @@ -919,7 +919,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Doubles, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Doubles, will throw an exception' ); } @isTest @@ -953,7 +953,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Decimal, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Decimal, will throw an exception' ); } @isTest @@ -987,7 +987,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Decimals, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Decimals, will throw an exception' ); } @isTest @@ -1024,7 +1024,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Dates, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Dates, will throw an exception' ); } @isTest @@ -1061,7 +1061,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Dates, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Dates, will throw an exception' ); } @isTest @@ -1098,7 +1098,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of DateTime, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of DateTime, will throw an exception' ); } @isTest @@ -1135,7 +1135,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of DateTime, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of DateTime, will throw an exception' ); } @isTest @@ -1169,7 +1169,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Objects, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a field and an empty set of Objects, will throw an exception' ); } @isTest private static void inSet_stringName_objectValues_whenCalled_addsAnInToTheGeneratedSoql() // NOPMD: Test method name format @@ -1202,7 +1202,7 @@ private without sharing class ortoo_CriteriaTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Objects, will throw an exception' ); + ortoo_Asserts.assertContains( 'inSet called with an empty values', exceptionMessage, 'isSet, when called with a string field name and an empty set of Objects, will throw an exception' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DomainFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DomainFactoryTest.cls index 20abdb515fe..9459fddc147 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DomainFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DomainFactoryTest.cls @@ -72,7 +72,7 @@ private without sharing class ortoo_DomainFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getDomainType called with a null sobjectType', exceptionMessage, 'getDomainType, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'getDomainType called with a null sobjectType', exceptionMessage, 'getDomainType, when called with null, will throw an exception' ); } public inherited sharing class RegisterableType {} diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DynamicSobjectSelectorTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DynamicSobjectSelectorTest.cls index b611ee8c7b4..50c3a379649 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DynamicSobjectSelectorTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DynamicSobjectSelectorTest.cls @@ -40,7 +40,7 @@ private without sharing class ortoo_DynamicSobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'selectByCriteria called when sobjectType has not been set', exceptionMessage, 'selectByCriteria, when the sobject type has not been set, will throw an exception' ); + ortoo_Asserts.assertContains( 'selectByCriteria called when sobjectType has not been set', exceptionMessage, 'selectByCriteria, when the sobject type has not been set, will throw an exception' ); } @isTest @@ -61,7 +61,7 @@ private without sharing class ortoo_DynamicSobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'selectByCriteria called with a null criteria', exceptionMessage, 'selectByCriteria, when given a null criteria, will throw an exception' ); + ortoo_Asserts.assertContains( 'selectByCriteria called with a null criteria', exceptionMessage, 'selectByCriteria, when given a null criteria, will throw an exception' ); } @isTest @@ -112,7 +112,7 @@ private without sharing class ortoo_DynamicSobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addField called with a null fieldToAdd', exceptionMessage, 'addField, when passed a null field name, will throw an exception' ); + ortoo_Asserts.assertContains( 'addField called with a null fieldToAdd', exceptionMessage, 'addField, when passed a null field name, will throw an exception' ); } @isTest @@ -134,7 +134,7 @@ private without sharing class ortoo_DynamicSobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setSobjectType called with a null sobjectTypeName', exceptionMessage, 'setSobjectType, when passed a null string, will throw an exception' ); + ortoo_Asserts.assertContains( 'setSobjectType called with a null sobjectTypeName', exceptionMessage, 'setSobjectType, when passed a null string, will throw an exception' ); } @isTest @@ -154,7 +154,7 @@ private without sharing class ortoo_DynamicSobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setSobjectType called with an sobjectTypeName that does not represent a valid SObject Type', exceptionMessage, 'setSobjectType, when passed a string that does not represent an sobject, will throw an exception' ); + ortoo_Asserts.assertContains( 'setSobjectType called with an sobjectTypeName that does not represent a valid SObject Type', exceptionMessage, 'setSobjectType, when passed a string that does not represent an sobject, will throw an exception' ); } @isTest @@ -176,7 +176,7 @@ private without sharing class ortoo_DynamicSobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setSobjectType called with a null sobjectType', exceptionMessage, 'setSobjectType, when passed a null sobject type, will throw an exception' ); + ortoo_Asserts.assertContains( 'setSobjectType called with a null sobjectType', exceptionMessage, 'setSobjectType, when passed a null sobject type, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_MessageRendererFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_MessageRendererFactoryTest.cls index 3d65b6972a1..12d8ab52485 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_MessageRendererFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_MessageRendererFactoryTest.cls @@ -85,7 +85,7 @@ private without sharing class ortoo_MessageRendererFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_MessageRendererFactoryTest.NonRegisterableType does not implement MessageRendererEngine.IMessageRenderer', exceptionMessage, 'newInstance, when called for an unmapped type that does not implement IMessageRenderer, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_MessageRendererFactoryTest.NonRegisterableType does not implement MessageRendererEngine.IMessageRenderer', exceptionMessage, 'newInstance, when called for an unmapped type that does not implement IMessageRenderer, will throw an exception' ); } @isTest @@ -113,7 +113,7 @@ private without sharing class ortoo_MessageRendererFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Object does not implement MessageRendererEngine.IMessageRenderer', exceptionMessage, 'newInstance, when called for a mapped type that does not implement IMessageRenderer, will throw an exception' ); + ortoo_Asserts.assertContains( 'Object does not implement MessageRendererEngine.IMessageRenderer', exceptionMessage, 'newInstance, when called for a mapped type that does not implement IMessageRenderer, will throw an exception' ); } @isTest @@ -136,7 +136,7 @@ private without sharing class ortoo_MessageRendererFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null type, will throw an exception' ); + ortoo_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null type, will throw an exception' ); } @isTest private static void newInstance_whenCalledWithANullMessage_willThrowAnException() // NOPMD: Test method name format @@ -155,7 +155,7 @@ private without sharing class ortoo_MessageRendererFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'newInstance called with a null message', exceptionMessage, 'newInstance, when called with null message, will throw an exception' ); + ortoo_Asserts.assertContains( 'newInstance called with a null message', exceptionMessage, 'newInstance, when called with null message, will throw an exception' ); } @isTest @@ -176,7 +176,7 @@ private without sharing class ortoo_MessageRendererFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_MessageRendererFactory instantiated with a null implementationPerType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_MessageRendererFactory instantiated with a null implementationPerType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); } private without sharing class RegisterableType implements IMessageRenderer diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SelectorFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SelectorFactoryTest.cls index e3c12692969..2663175fd0f 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SelectorFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SelectorFactoryTest.cls @@ -49,7 +49,7 @@ private without sharing class ortoo_SelectorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getSelectorType called with a null sobjectType', exceptionMessage, 'getSelectorType, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'getSelectorType called with a null sobjectType', exceptionMessage, 'getSelectorType, when called with null, will throw an exception' ); } public inherited sharing class RegisterableType {} diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ServiceFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ServiceFactoryTest.cls index 0a40b5ed28b..0f9d632969c 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ServiceFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_ServiceFactoryTest.cls @@ -90,7 +90,7 @@ public without sharing class ortoo_ServiceFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isRegisteredAsAnImplementation called with a null className', exceptionMessage, 'isRegisteredAsAnImplementation, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'isRegisteredAsAnImplementation called with a null className', exceptionMessage, 'isRegisteredAsAnImplementation, when called with null, will throw an exception' ); } public inherited sharing class RegisterableType implements IRegisterableType {} diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SimpleObjectFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SimpleObjectFactoryTest.cls index a9550bf27d8..432e1ced967 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SimpleObjectFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SimpleObjectFactoryTest.cls @@ -42,7 +42,7 @@ private without sharing class ortoo_SimpleObjectFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NonConstructableType does not have parameterless constructor', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); + ortoo_Asserts.assertContains( 'NonConstructableType does not have parameterless constructor', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); } @isTest @@ -113,7 +113,7 @@ private without sharing class ortoo_SimpleObjectFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'No implementation registered for', exceptionMessage, 'newInstance, when set to not allow unmapped, and called with an unmapped, will throw an exception' ); + ortoo_Asserts.assertContains( 'No implementation registered for', exceptionMessage, 'newInstance, when set to not allow unmapped, and called with an unmapped, will throw an exception' ); } @isTest @@ -155,7 +155,7 @@ private without sharing class ortoo_SimpleObjectFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'No implementation registered for thingy', exceptionMessage, 'setTypeName, when an error occurs, will set the name of the type in the message' ); + ortoo_Asserts.assertContains( 'No implementation registered for thingy', exceptionMessage, 'setTypeName, when an error occurs, will set the name of the type in the message' ); } @isTest @@ -175,7 +175,7 @@ private without sharing class ortoo_SimpleObjectFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setTypeName called with a null typeName', exceptionMessage, 'setTypeName, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'setTypeName called with a null typeName', exceptionMessage, 'setTypeName, when called with null, will throw an exception' ); } @isTest @@ -195,7 +195,7 @@ private without sharing class ortoo_SimpleObjectFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'newInstance called with a null requestedType', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); } @isTest @@ -215,7 +215,7 @@ private without sharing class ortoo_SimpleObjectFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setErrorOnUnmappedType called with a null errorOnUnmappedType', exceptionMessage, 'setErrorOnUnmappedType, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'setErrorOnUnmappedType called with a null errorOnUnmappedType', exceptionMessage, 'setErrorOnUnmappedType, when called with null, will throw an exception' ); } @isTest @@ -233,7 +233,7 @@ private without sharing class ortoo_SimpleObjectFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_SimpleObjectFactory instantiated with a null implementationByType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_SimpleObjectFactory instantiated with a null implementationByType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); } private without sharing class RegisterableType diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectDomainTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectDomainTest.cls index cc35ba9906d..afec822236e 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectDomainTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectDomainTest.cls @@ -57,7 +57,7 @@ private without sharing class ortoo_SobjectDomainTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'triggerHandler called with a null domainClass', exceptionMessage, 'triggerHandler, when passed a null domainClass, will throw an exception' ); + ortoo_Asserts.assertContains( 'triggerHandler called with a null domainClass', exceptionMessage, 'triggerHandler, when passed a null domainClass, will throw an exception' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectSelectorTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectSelectorTest.cls index b2978c5adc6..32115140e56 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectSelectorTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectSelectorTest.cls @@ -180,7 +180,7 @@ private without sharing class ortoo_SobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Attempted to perform the count of an unbound query against ' + Account.sobjectType.getDescribe().getName(), exceptionMessage, 'selectBySearchCriteria, when given empty criteria, will throw an exception' ); + ortoo_Asserts.assertContains( 'Attempted to perform the count of an unbound query against ' + Account.sobjectType.getDescribe().getName(), exceptionMessage, 'selectBySearchCriteria, when given empty criteria, will throw an exception' ); } @isTest @@ -202,7 +202,7 @@ private without sharing class ortoo_SobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'selectBySearchCriteria called with a null searchConfiguration', exceptionMessage, 'selectBySearchCriteria, when passed a null searchConfiguration, will throw an exception' ); + ortoo_Asserts.assertContains( 'selectBySearchCriteria called with a null searchConfiguration', exceptionMessage, 'selectBySearchCriteria, when passed a null searchConfiguration, will throw an exception' ); } @isTest @@ -224,7 +224,7 @@ private without sharing class ortoo_SobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'selectBySearchCriteria called with a null criteria', exceptionMessage, 'selectBySearchCriteria, when passed a null criteria, will throw an exception' ); + ortoo_Asserts.assertContains( 'selectBySearchCriteria called with a null criteria', exceptionMessage, 'selectBySearchCriteria, when passed a null criteria, will throw an exception' ); } @isTest @@ -246,7 +246,7 @@ private without sharing class ortoo_SobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'selectBySearchCriteria called with a null window', exceptionMessage, 'selectBySearchCriteria, when passed a null window, will throw an exception' ); + ortoo_Asserts.assertContains( 'selectBySearchCriteria called with a null window', exceptionMessage, 'selectBySearchCriteria, when passed a null window, will throw an exception' ); } @isTest @@ -268,7 +268,7 @@ private without sharing class ortoo_SobjectSelectorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'selectBySearchCriteria called with a null orderBy', exceptionMessage, 'selectBySearchCriteria, when passed a null orderBy, will throw an exception' ); + ortoo_Asserts.assertContains( 'selectBySearchCriteria called with a null orderBy', exceptionMessage, 'selectBySearchCriteria, when passed a null orderBy, will throw an exception' ); } class TestableSelector extends ortoo_SobjectSelector diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectValidatorFactoryTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectValidatorFactoryTest.cls index b1d33fdac7e..acdf249d016 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectValidatorFactoryTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_SobjectValidatorFactoryTest.cls @@ -41,7 +41,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NonConstructableType does not have parameterless constructor', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); + ortoo_Asserts.assertContains( 'NonConstructableType does not have parameterless constructor', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); } @isTest @@ -65,7 +65,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_SobjectValidatorFactoryTest.NonRegisterableType is not an implementation of ISobjectValidator', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_SobjectValidatorFactoryTest.NonRegisterableType is not an implementation of ISobjectValidator', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); } @isTest @@ -90,7 +90,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'No implementation registered for', exceptionMessage, 'newInstance, when called with an unmapped, will throw an exception' ); + ortoo_Asserts.assertContains( 'No implementation registered for', exceptionMessage, 'newInstance, when called with an unmapped, will throw an exception' ); } @isTest @@ -146,7 +146,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'newInstance called with a null sobjectToValidate', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'newInstance called with a null sobjectToValidate', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); } @isTest @@ -187,7 +187,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'NonConstructableType does not have parameterless constructor', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); + ortoo_Asserts.assertContains( 'NonConstructableType does not have parameterless constructor', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); } @isTest @@ -211,7 +211,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_SobjectValidatorFactoryTest.NonRegisterableType is not an implementation of ISobjectValidator', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_SobjectValidatorFactoryTest.NonRegisterableType is not an implementation of ISobjectValidator', exceptionMessage, 'newInstance, when called with a type that cannot be constructed, will throw an exception' ); } @isTest @@ -236,7 +236,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'No implementation registered for', exceptionMessage, 'newInstance, when called with an unmapped, will throw an exception' ); + ortoo_Asserts.assertContains( 'No implementation registered for', exceptionMessage, 'newInstance, when called with an unmapped, will throw an exception' ); } @isTest @@ -292,7 +292,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'newInstance called with a null sobjectsToValidate', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'newInstance called with a null sobjectsToValidate', exceptionMessage, 'newInstance, when called with null, will throw an exception' ); } @isTest @@ -310,7 +310,7 @@ private without sharing class ortoo_SobjectValidatorFactoryTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'ortoo_SobjectValidatorFactory instantiated with a null validatorBySobjectType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'ortoo_SobjectValidatorFactory instantiated with a null validatorBySobjectType', exceptionMessage, 'constructor, when called with null, will throw an exception' ); } public without sharing class RegisterableType implements ISobjectValidator diff --git a/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageDetailTest.cls b/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageDetailTest.cls index 4ffa6af4722..9f92ced6dcf 100644 --- a/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageDetailTest.cls +++ b/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageDetailTest.cls @@ -164,6 +164,6 @@ private without sharing class MessageDetailTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setSeverity called with a null severity', exceptionMessage, 'setSeverity, when passed null, will throw an exception' ); + ortoo_Asserts.assertContains( 'setSeverity called with a null severity', exceptionMessage, 'setSeverity, when passed null, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageRendererEngineTest.cls b/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageRendererEngineTest.cls index 4f2dd628439..6c4b1bfa353 100644 --- a/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageRendererEngineTest.cls +++ b/framework/default/ortoo-core/default/classes/message-renderer-engine/tests/MessageRendererEngineTest.cls @@ -20,7 +20,7 @@ private without sharing class MessageRendererEngineTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'render called before the renderer was set', exceptionMessage, 'render, when no renderer has been set, will throw an exception' ); + ortoo_Asserts.assertContains( 'render called before the renderer was set', exceptionMessage, 'render, when no renderer has been set, will throw an exception' ); } @isTest @@ -42,7 +42,7 @@ private without sharing class MessageRendererEngineTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'render called before the message was set', exceptionMessage, 'render, when no message has been set, will throw an exception' ); + ortoo_Asserts.assertContains( 'render called before the message was set', exceptionMessage, 'render, when no message has been set, will throw an exception' ); } @isTest @@ -110,7 +110,7 @@ private without sharing class MessageRendererEngineTest messageController.verify(); - Amoss_Asserts.assertContains( 'Call to render messages was called, but no message was rendered', thrownException.getMessage(), 'render, when the renderer returns false, will throw an exception' ); + ortoo_Asserts.assertContains( 'Call to render messages was called, but no message was rendered', thrownException.getMessage(), 'render, when the renderer returns false, will throw an exception' ); ortoo_Exception.Contexts contexts = thrownException.getContexts(); ortoo_Exception.Context context; diff --git a/framework/default/ortoo-core/default/classes/search/tests/SearchConfigurationTest.cls b/framework/default/ortoo-core/default/classes/search/tests/SearchConfigurationTest.cls index 865d7fcc2a9..4b38b6110a5 100644 --- a/framework/default/ortoo-core/default/classes/search/tests/SearchConfigurationTest.cls +++ b/framework/default/ortoo-core/default/classes/search/tests/SearchConfigurationTest.cls @@ -16,7 +16,7 @@ public inherited sharing class SearchConfigurationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'constructor called with a null baseSobjectType', exceptionMessage, 'constructor, when passed a null baseSobjectType, will throw an exception' ); + ortoo_Asserts.assertContains( 'constructor called with a null baseSobjectType', exceptionMessage, 'constructor, when passed a null baseSobjectType, will throw an exception' ); } @isTest @@ -138,7 +138,7 @@ public inherited sharing class SearchConfigurationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getMappedSobjectField called with a blank resultField', exceptionMessage, 'getMappedSobjectField, when passed a null result field, will throw an exception' ); + ortoo_Asserts.assertContains( 'getMappedSobjectField called with a blank resultField', exceptionMessage, 'getMappedSobjectField, when passed a null result field, will throw an exception' ); } @isTest @@ -158,7 +158,7 @@ public inherited sharing class SearchConfigurationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getMappedSobjectField called with a blank resultField', exceptionMessage, 'getMappedSobjectField, when passed a null result field, will throw an exception' ); + ortoo_Asserts.assertContains( 'getMappedSobjectField called with a blank resultField', exceptionMessage, 'getMappedSobjectField, when passed a null result field, will throw an exception' ); } @isTest @@ -178,7 +178,7 @@ public inherited sharing class SearchConfigurationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addFieldMapping called with a blank resultField', exceptionMessage, 'addFieldMapping, when passed a null result field, will throw an exception' ); + ortoo_Asserts.assertContains( 'addFieldMapping called with a blank resultField', exceptionMessage, 'addFieldMapping, when passed a null result field, will throw an exception' ); } @isTest @@ -198,7 +198,7 @@ public inherited sharing class SearchConfigurationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addFieldMapping called with a blank resultField', exceptionMessage, 'addFieldMapping, when passed a blank result field, will throw an exception' ); + ortoo_Asserts.assertContains( 'addFieldMapping called with a blank resultField', exceptionMessage, 'addFieldMapping, when passed a blank result field, will throw an exception' ); } @isTest @@ -218,7 +218,7 @@ public inherited sharing class SearchConfigurationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addFieldMapping called with a blank sobjectField', exceptionMessage, 'addFieldMapping, when passed a null sobject field, will throw an exception' ); + ortoo_Asserts.assertContains( 'addFieldMapping called with a blank sobjectField', exceptionMessage, 'addFieldMapping, when passed a null sobject field, will throw an exception' ); } @isTest @@ -238,7 +238,7 @@ public inherited sharing class SearchConfigurationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addFieldMapping called with a blank sobjectField', exceptionMessage, 'addFieldMapping, when passed a blank sobject field, will throw an exception' ); + ortoo_Asserts.assertContains( 'addFieldMapping called with a blank sobjectField', exceptionMessage, 'addFieldMapping, when passed a blank sobject field, will throw an exception' ); } class TestableSearchConfiguration extends SearchConfiguration diff --git a/framework/default/ortoo-core/default/classes/search/tests/SearchControllerTest.cls b/framework/default/ortoo-core/default/classes/search/tests/SearchControllerTest.cls index 0b2b77dce88..d433bc6fe9f 100644 --- a/framework/default/ortoo-core/default/classes/search/tests/SearchControllerTest.cls +++ b/framework/default/ortoo-core/default/classes/search/tests/SearchControllerTest.cls @@ -20,7 +20,7 @@ public inherited sharing class SearchControllerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setSearchConfigurationType called with a null searchConfigurationType', exceptionMessage, 'setSearchConfigurationType, when passed a null searchConfigurationType, will throw an exception' ); + ortoo_Asserts.assertContains( 'setSearchConfigurationType called with a null searchConfigurationType', exceptionMessage, 'setSearchConfigurationType, when passed a null searchConfigurationType, will throw an exception' ); } @isTest @@ -109,7 +109,7 @@ public inherited sharing class SearchControllerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null searchCriteriaFactory', exceptionMessage, 'search, when passed a null searchCriteriaFactory, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null searchCriteriaFactory', exceptionMessage, 'search, when passed a null searchCriteriaFactory, will throw an exception' ); } @isTest @@ -130,7 +130,7 @@ public inherited sharing class SearchControllerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null criteria', exceptionMessage, 'search, when passed a null criteria, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null criteria', exceptionMessage, 'search, when passed a null criteria, will throw an exception' ); } @isTest @@ -151,7 +151,7 @@ public inherited sharing class SearchControllerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null window', exceptionMessage, 'search, when passed a null window, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null window', exceptionMessage, 'search, when passed a null window, will throw an exception' ); } @isTest @@ -172,7 +172,7 @@ public inherited sharing class SearchControllerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null orderBy', exceptionMessage, 'search, when passed a null orderBy, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null orderBy', exceptionMessage, 'search, when passed a null orderBy, will throw an exception' ); } @isTest @@ -192,7 +192,7 @@ public inherited sharing class SearchControllerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called when searchConfigurationType was null', exceptionMessage, 'search, when searchConfigurationType is not configured, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called when searchConfigurationType was null', exceptionMessage, 'search, when searchConfigurationType is not configured, will throw an exception' ); } @isTest @@ -232,6 +232,6 @@ public inherited sharing class SearchControllerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getSortableFields called when searchConfigurationType was null', exceptionMessage, 'getSortableFields,when searchConfigurationType is not configured, will throw an exception' ); + ortoo_Asserts.assertContains( 'getSortableFields called when searchConfigurationType was null', exceptionMessage, 'getSortableFields,when searchConfigurationType is not configured, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/search/tests/SearchOrderByTest.cls b/framework/default/ortoo-core/default/classes/search/tests/SearchOrderByTest.cls index 3c9ed4faa44..dea7bbf2dd4 100644 --- a/framework/default/ortoo-core/default/classes/search/tests/SearchOrderByTest.cls +++ b/framework/default/ortoo-core/default/classes/search/tests/SearchOrderByTest.cls @@ -202,7 +202,7 @@ public inherited sharing class SearchOrderByTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with an invalid direction. Was "invalid", but should be one of [asc,desc]', exceptionMessage, 'configure, when passed an invalid direction, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with an invalid direction. Was "invalid", but should be one of [asc,desc]', exceptionMessage, 'configure, when passed an invalid direction, will throw an exception' ); } @isTest @@ -220,7 +220,7 @@ public inherited sharing class SearchOrderByTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a null properties', exceptionMessage, 'configure, when passed a null properties, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a null properties', exceptionMessage, 'configure, when passed a null properties, will throw an exception' ); } @isTest @@ -238,7 +238,7 @@ public inherited sharing class SearchOrderByTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a null searchConfigurationType', exceptionMessage, 'configure, when passed a null searchConfigurationType, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a null searchConfigurationType', exceptionMessage, 'configure, when passed a null searchConfigurationType, will throw an exception' ); } @isTest @@ -256,7 +256,7 @@ public inherited sharing class SearchOrderByTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a searchConfigurationType ('+SearchOrderByTest.class+') that does not implement ISearchConfiguration or does not have a parameterless constructor', exceptionMessage, 'configure, when passed an invalid searchConfigurationType, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a searchConfigurationType ('+SearchOrderByTest.class+') that does not implement ISearchConfiguration or does not have a parameterless constructor', exceptionMessage, 'configure, when passed an invalid searchConfigurationType, will throw an exception' ); } @isTest @@ -274,7 +274,7 @@ public inherited sharing class SearchOrderByTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a searchConfigurationType ('+SearchOrderByTest.NoParameterlessConstructor.class+') that does not implement ISearchConfiguration or does not have a parameterless constructor', exceptionMessage, 'configure, when passed an invalid searchConfigurationType, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a searchConfigurationType ('+SearchOrderByTest.NoParameterlessConstructor.class+') that does not implement ISearchConfiguration or does not have a parameterless constructor', exceptionMessage, 'configure, when passed an invalid searchConfigurationType, will throw an exception' ); } diff --git a/framework/default/ortoo-core/default/classes/search/tests/SearchResultsTest.cls b/framework/default/ortoo-core/default/classes/search/tests/SearchResultsTest.cls index 37ccd0c9678..ddfc52ed88b 100644 --- a/framework/default/ortoo-core/default/classes/search/tests/SearchResultsTest.cls +++ b/framework/default/ortoo-core/default/classes/search/tests/SearchResultsTest.cls @@ -44,7 +44,7 @@ public inherited sharing class SearchResultsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'constructor called with a null totalNumberOfRecords', exceptionMessage, 'constructor, when passed a null totalNumberOfRecords, will throw an exception' ); + ortoo_Asserts.assertContains( 'constructor called with a null totalNumberOfRecords', exceptionMessage, 'constructor, when passed a null totalNumberOfRecords, will throw an exception' ); } @isTest @@ -62,7 +62,7 @@ public inherited sharing class SearchResultsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'constructor called with a negative totalNumberOfRecords', exceptionMessage, 'constructor, when passed a negative totalNumberOfRecords, will throw an exception' ); + ortoo_Asserts.assertContains( 'constructor called with a negative totalNumberOfRecords', exceptionMessage, 'constructor, when passed a negative totalNumberOfRecords, will throw an exception' ); } @isTest @@ -80,7 +80,7 @@ public inherited sharing class SearchResultsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'constructor called with a null records', exceptionMessage, 'constructor, when passed a null records, will throw an exception' ); + ortoo_Asserts.assertContains( 'constructor called with a null records', exceptionMessage, 'constructor, when passed a null records, will throw an exception' ); } @isTest @@ -98,7 +98,7 @@ public inherited sharing class SearchResultsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'constructor called with a totalNumberOfRecords that is lower than the size of records', exceptionMessage, 'constructor, when passed a total number of records that is lower than the number of records, will throw an exception' ); + ortoo_Asserts.assertContains( 'constructor called with a totalNumberOfRecords that is lower than the size of records', exceptionMessage, 'constructor, when passed a total number of records that is lower than the number of records, will throw an exception' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/search/tests/SearchWindowTest.cls b/framework/default/ortoo-core/default/classes/search/tests/SearchWindowTest.cls index 050c9abcf75..c931e1d9718 100644 --- a/framework/default/ortoo-core/default/classes/search/tests/SearchWindowTest.cls +++ b/framework/default/ortoo-core/default/classes/search/tests/SearchWindowTest.cls @@ -47,7 +47,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a null properties', exceptionMessage, 'configure, when passed a null properties, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a null properties', exceptionMessage, 'configure, when passed a null properties, will throw an exception' ); } @isTest @@ -171,7 +171,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a negative offset', exceptionMessage, 'configure, when given a negative offset, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a negative offset', exceptionMessage, 'configure, when given a negative offset, will throw an exception' ); } @isTest @@ -193,7 +193,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a negative offset', exceptionMessage, 'configure, when given a negative string offset, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a negative offset', exceptionMessage, 'configure, when given a negative string offset, will throw an exception' ); } @isTest @@ -215,7 +215,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a negative length, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a negative length, will throw an exception' ); } @isTest @@ -237,7 +237,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a negative string length, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a negative string length, will throw an exception' ); } @isTest @@ -259,7 +259,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a zero length, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a zero length, will throw an exception' ); } @isTest @@ -281,7 +281,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a zero string length, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with a negative or zero length', exceptionMessage, 'configure, when given a zero string length, will throw an exception' ); } @isTest @@ -303,7 +303,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with offset that could not be cast into an Integer', exceptionMessage, 'configure, when given a non numeric offset, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with offset that could not be cast into an Integer', exceptionMessage, 'configure, when given a non numeric offset, will throw an exception' ); } @isTest @@ -325,7 +325,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with offset that could not be cast into an Integer', exceptionMessage, 'configure, when given a numeric string offset that cannot be cast to an integer, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with offset that could not be cast into an Integer', exceptionMessage, 'configure, when given a numeric string offset that cannot be cast to an integer, will throw an exception' ); } @isTest @@ -347,7 +347,7 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with length that could not be cast into an Integer', exceptionMessage, 'configure, when given a non numeric length, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with length that could not be cast into an Integer', exceptionMessage, 'configure, when given a non numeric length, will throw an exception' ); } @@ -370,6 +370,6 @@ public inherited sharing class SearchWindowTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'configure called with length that could not be cast into an Integer', exceptionMessage, 'configure, when given a numeric string length that cannot be cast to an integer, will throw an exception' ); + ortoo_Asserts.assertContains( 'configure called with length that could not be cast into an Integer', exceptionMessage, 'configure, when given a numeric string length that cannot be cast to an integer, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildContextTest.cls b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildContextTest.cls index c06301670a5..27492138bda 100644 --- a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildContextTest.cls +++ b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildContextTest.cls @@ -16,7 +16,7 @@ private without sharing class DmlChildContextTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'DmlChildContext was constructed with a null relatedByField', exceptionMessage, 'constructor, when called with a null field, will throw an exception' ); + ortoo_Asserts.assertContains( 'DmlChildContext was constructed with a null relatedByField', exceptionMessage, 'constructor, when called with a null field, will throw an exception' ); } @isTest @@ -34,7 +34,7 @@ private without sharing class DmlChildContextTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'DmlChildContext was constructed with a null childFinderType', exceptionMessage, 'constructor, when called with a null finder type, will throw an exception' ); + ortoo_Asserts.assertContains( 'DmlChildContext was constructed with a null childFinderType', exceptionMessage, 'constructor, when called with a null finder type, will throw an exception' ); } @isTest @@ -77,7 +77,7 @@ private without sharing class DmlChildContextTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setParent was called with a null parent', exceptionMessage, 'setParent, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'setParent was called with a null parent', exceptionMessage, 'setParent, when called with null, will throw an exception' ); } @isTest @@ -97,7 +97,7 @@ private without sharing class DmlChildContextTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'registerRelationship was called with a null unit of work', exceptionMessage, 'registerRelationship, when called with uow, will throw an exception' ); + ortoo_Asserts.assertContains( 'registerRelationship was called with a null unit of work', exceptionMessage, 'registerRelationship, when called with uow, will throw an exception' ); } @isTest @@ -117,7 +117,7 @@ private without sharing class DmlChildContextTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'registerRelationship was called with a null child', exceptionMessage, 'registerRelationship, when called with child, will throw an exception' ); + ortoo_Asserts.assertContains( 'registerRelationship was called with a null child', exceptionMessage, 'registerRelationship, when called with child, will throw an exception' ); } @isTest @@ -137,7 +137,7 @@ private without sharing class DmlChildContextTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'registerRelationship was called before a parent was set', exceptionMessage, 'registerRelationship, when called before a parent is set, will throw an exception' ); + ortoo_Asserts.assertContains( 'registerRelationship was called before a parent was set', exceptionMessage, 'registerRelationship, when called before a parent is set, will throw an exception' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildrenToDeleteRegisterTest.cls b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildrenToDeleteRegisterTest.cls index 076b4a0f06d..858aa73ad4e 100644 --- a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildrenToDeleteRegisterTest.cls +++ b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlChildrenToDeleteRegisterTest.cls @@ -140,7 +140,7 @@ private without sharing class DmlChildrenToDeleteRegisterTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'registerChildContextAndParent called with a null childContext', exceptionMessage, 'registerChildContextAndParent, when given a null child context, will throw an exception' ); + ortoo_Asserts.assertContains( 'registerChildContextAndParent called with a null childContext', exceptionMessage, 'registerChildContextAndParent, when given a null child context, will throw an exception' ); } @isTest @@ -167,7 +167,7 @@ private without sharing class DmlChildrenToDeleteRegisterTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'registerChildContextAndParent called with a DmlChildContext that returns a null Child Finder Type', exceptionMessage, 'registerChildContextAndParent, when getChildFinderType returns null, will throw an exception' ); + ortoo_Asserts.assertContains( 'registerChildContextAndParent called with a DmlChildContext that returns a null Child Finder Type', exceptionMessage, 'registerChildContextAndParent, when getChildFinderType returns null, will throw an exception' ); } @isTest @@ -197,7 +197,7 @@ private without sharing class DmlChildrenToDeleteRegisterTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'registerChildContextAndParent called with a DmlChildContext that returns a null Child Finder', exceptionMessage, 'registerChildContextAndParent, when getChildFinder returns null, will throw an exception' ); + ortoo_Asserts.assertContains( 'registerChildContextAndParent called with a DmlChildContext that returns a null Child Finder', exceptionMessage, 'registerChildContextAndParent, when getChildFinder returns null, will throw an exception' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerOptionsTest.cls b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerOptionsTest.cls index 749b462cdad..9bb441ad244 100644 --- a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerOptionsTest.cls +++ b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerOptionsTest.cls @@ -37,6 +37,6 @@ private without sharing class DmlDefinerOptionsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setOtherRecordsMode called with a null otherRecordsMode', exceptionMessage, 'setOtherRecordsMode, when called with null, will throw an exception' ); + ortoo_Asserts.assertContains( 'setOtherRecordsMode called with a null otherRecordsMode', exceptionMessage, 'setOtherRecordsMode, when called with null, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerTest.cls b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerTest.cls index 3ad93f78766..8a38bcfa890 100644 --- a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerTest.cls +++ b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlDefinerTest.cls @@ -82,7 +82,7 @@ private without sharing class DmlDefinerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addRecord called with a null record', exceptionMessage, 'addRecord, when given null, will throw an exception' ); + ortoo_Asserts.assertContains( 'addRecord called with a null record', exceptionMessage, 'addRecord, when given null, will throw an exception' ); } @isTest @@ -129,7 +129,7 @@ private without sharing class DmlDefinerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addRecords called with a null list', exceptionMessage, 'addRecords, when given null, will throw an exception' ); + ortoo_Asserts.assertContains( 'addRecords called with a null list', exceptionMessage, 'addRecords, when given null, will throw an exception' ); } @isTest @@ -163,7 +163,7 @@ private without sharing class DmlDefinerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setOptions called with a null options', exceptionMessage, 'setOptions, when given null, will throw an exception' ); + ortoo_Asserts.assertContains( 'setOptions called with a null options', exceptionMessage, 'setOptions, when given null, will throw an exception' ); } @isTest @@ -309,6 +309,6 @@ private without sharing class DmlDefinerTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addPreSaveAction called with a null action', exceptionMessage, 'addPreSaveAction, when given null, will throw an exception' ); + ortoo_Asserts.assertContains( 'addPreSaveAction called with a null action', exceptionMessage, 'addPreSaveAction, when given null, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlRecordTest.cls b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlRecordTest.cls index 6f5050455e5..eeec1a08978 100644 --- a/framework/default/ortoo-core/default/classes/services/dml/tests/DmlRecordTest.cls +++ b/framework/default/ortoo-core/default/classes/services/dml/tests/DmlRecordTest.cls @@ -27,7 +27,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'DmlRecord constructor called with a null recordToDml', exceptionMessage, 'constructor, when given null, will throw an exception' ); + ortoo_Asserts.assertContains( 'DmlRecord constructor called with a null recordToDml', exceptionMessage, 'constructor, when given null, will throw an exception' ); } @isTest @@ -60,7 +60,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChildContext called with a null childRecordType', exceptionMessage, 'addChildContext, when called with a null type, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChildContext called with a null childRecordType', exceptionMessage, 'addChildContext, when called with a null type, will throw an exception' ); } @isTest @@ -79,7 +79,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChildContext called with a null childContext', exceptionMessage, 'addChildContext, when called with a null childContext, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChildContext called with a null childContext', exceptionMessage, 'addChildContext, when called with a null childContext, will throw an exception' ); } @isTest @@ -115,7 +115,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'InvalidType', exceptionMessage, 'addChild, when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'InvalidType', exceptionMessage, 'addChild, when given a child type that does not exist, will throw an exception' ); } @isTest @@ -135,7 +135,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChild called with a null childRecordType', exceptionMessage, 'addChild, when given a null child type, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChild called with a null childRecordType', exceptionMessage, 'addChild, when given a null child type, will throw an exception' ); } @isTest @@ -155,7 +155,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChild called with a null childRecord', exceptionMessage, 'addChild, when given a null child context, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChild called with a null childRecord', exceptionMessage, 'addChild, when given a null child context, will throw an exception' ); } @isTest @@ -195,7 +195,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'InvalidType', exceptionMessage, 'addChildren, when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'InvalidType', exceptionMessage, 'addChildren, when given a child type that does not exist, will throw an exception' ); } @isTest @@ -215,7 +215,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChildren called with a null childRecordType', exceptionMessage, 'addChildren, when given a null child type, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChildren called with a null childRecordType', exceptionMessage, 'addChildren, when given a null child type, will throw an exception' ); } @isTest @@ -235,7 +235,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChildren called with a null childRecords', exceptionMessage, 'addChildren, when given a null child context, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChildren called with a null childRecords', exceptionMessage, 'addChildren, when given a null child context, will throw an exception' ); } @isTest @@ -279,7 +279,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'InvalidType', exceptionMessage, 'setChild, when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'InvalidType', exceptionMessage, 'setChild, when given a child type that does not exist, will throw an exception' ); } @isTest @@ -299,7 +299,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChild called with a null childRecordType', exceptionMessage, 'setChild, when given a null child type, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChild called with a null childRecordType', exceptionMessage, 'setChild, when given a null child type, will throw an exception' ); } @isTest @@ -319,7 +319,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChild called with a null childRecord', exceptionMessage, 'setChild, when given a null child context, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChild called with a null childRecord', exceptionMessage, 'setChild, when given a null child context, will throw an exception' ); } @isTest @@ -366,7 +366,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'InvalidType', exceptionMessage, 'setChildren, when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'InvalidType', exceptionMessage, 'setChildren, when given a child type that does not exist, will throw an exception' ); } @isTest @@ -386,7 +386,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChildren called with a null childRecordType', exceptionMessage, 'setChildren, when given a null child type, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChildren called with a null childRecordType', exceptionMessage, 'setChildren, when given a null child type, will throw an exception' ); } @isTest @@ -408,7 +408,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChildren called with a null childRecords', exceptionMessage, 'setChildren, when given a null child context, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChildren called with a null childRecords', exceptionMessage, 'setChildren, when given a null child context, will throw an exception' ); } @isTest @@ -455,7 +455,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'InvalidType', exceptionMessage, 'setChildren (DmlDefiner), when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'InvalidType', exceptionMessage, 'setChildren (DmlDefiner), when given a child type that does not exist, will throw an exception' ); } @isTest @@ -475,7 +475,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChildren called with a null childRecordType', exceptionMessage, 'setChildren (DmlDefiner), when given a null child type, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChildren called with a null childRecordType', exceptionMessage, 'setChildren (DmlDefiner), when given a null child type, will throw an exception' ); } @isTest @@ -497,7 +497,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChildren called with a null childRecords', exceptionMessage, 'setChildren (DmlDefiner), when given a null child context, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChildren called with a null childRecords', exceptionMessage, 'setChildren (DmlDefiner), when given a null child context, will throw an exception' ); } @isTest @@ -517,7 +517,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Invalid', exceptionMessage, 'getChildDefiner, when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'Invalid', exceptionMessage, 'getChildDefiner, when given a child type that does not exist, will throw an exception' ); } @isTest @@ -553,7 +553,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Invalid', exceptionMessage, 'setChildDmlOptions, when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'Invalid', exceptionMessage, 'setChildDmlOptions, when given a child type that does not exist, will throw an exception' ); } @isTest @@ -574,7 +574,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChildDmlOptions called with a null childRecordType', exceptionMessage, 'setChildDmlOptions, when given a null child type, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChildDmlOptions called with a null childRecordType', exceptionMessage, 'setChildDmlOptions, when given a null child type, will throw an exception' ); } @isTest @@ -595,7 +595,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setChildDmlOptions called with a null options', exceptionMessage, 'setChildDmlOptions, when given a null options, will throw an exception' ); + ortoo_Asserts.assertContains( 'setChildDmlOptions called with a null options', exceptionMessage, 'setChildDmlOptions, when given a null options, will throw an exception' ); } @isTest @@ -632,7 +632,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Invalid', exceptionMessage, 'addChildPreSaveAction, when given a child type that does not exist, will throw an exception' ); + ortoo_Asserts.assertContains( 'Invalid', exceptionMessage, 'addChildPreSaveAction, when given a child type that does not exist, will throw an exception' ); } @isTest @@ -655,7 +655,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChildPreSaveAction called with a null childRecordType', exceptionMessage, 'addChildPreSaveAction, when given a null child type, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChildPreSaveAction called with a null childRecordType', exceptionMessage, 'addChildPreSaveAction, when given a null child type, will throw an exception' ); } @isTest @@ -676,7 +676,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addChildPreSaveAction called with a null action', exceptionMessage, 'addChildPreSaveAction, when given a null action, will throw an exception' ); + ortoo_Asserts.assertContains( 'addChildPreSaveAction called with a null action', exceptionMessage, 'addChildPreSaveAction, when given a null action, will throw an exception' ); } @isTest @@ -805,7 +805,7 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'saveSobject called with a null uow', exceptionMessage, 'saveSobject, when called with a null uow, will throw an exception' ); + ortoo_Asserts.assertContains( 'saveSobject called with a null uow', exceptionMessage, 'saveSobject, when called with a null uow, will throw an exception' ); } @isTest @@ -969,6 +969,6 @@ private without sharing class DmlRecordTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'registerChildrenToDelete called with a null register', exceptionMessage, 'registerChildrenToDelete, when called with a null register, will throw an exception' ); + ortoo_Asserts.assertContains( 'registerChildrenToDelete called with a null register', exceptionMessage, 'registerChildrenToDelete, when called with a null register, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/services/search-service/tests/SearchServiceImplTest.cls b/framework/default/ortoo-core/default/classes/services/search-service/tests/SearchServiceImplTest.cls index 73b670258f9..6af16e57bbc 100644 --- a/framework/default/ortoo-core/default/classes/services/search-service/tests/SearchServiceImplTest.cls +++ b/framework/default/ortoo-core/default/classes/services/search-service/tests/SearchServiceImplTest.cls @@ -114,7 +114,7 @@ public inherited sharing class SearchServiceImplTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null searchConfigurationType', exceptionMessage, 'search, when passed a null searchConfigurationType, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null searchConfigurationType', exceptionMessage, 'search, when passed a null searchConfigurationType, will throw an exception' ); } @isTest @@ -136,7 +136,7 @@ public inherited sharing class SearchServiceImplTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null criteria', exceptionMessage, 'search, when passed a null criteria, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null criteria', exceptionMessage, 'search, when passed a null criteria, will throw an exception' ); } @isTest @@ -158,7 +158,7 @@ public inherited sharing class SearchServiceImplTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null window', exceptionMessage, 'search, when passed a null window, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null window', exceptionMessage, 'search, when passed a null window, will throw an exception' ); } @isTest @@ -180,7 +180,7 @@ public inherited sharing class SearchServiceImplTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'search called with a null orderBy', exceptionMessage, 'search, when passed a null orderBy, will throw an exception' ); + ortoo_Asserts.assertContains( 'search called with a null orderBy', exceptionMessage, 'search, when passed a null orderBy, will throw an exception' ); } @isTest @@ -219,6 +219,6 @@ public inherited sharing class SearchServiceImplTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getSortableFields called with a null searchConfigurationType', exceptionMessage, 'getSortableFields, when passed a null searchConfigurationType, will throw an exception' ); + ortoo_Asserts.assertContains( 'getSortableFields called with a null searchConfigurationType', exceptionMessage, 'getSortableFields, when passed a null searchConfigurationType, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls b/framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls new file mode 100644 index 00000000000..2bf8d7befcb --- /dev/null +++ b/framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls @@ -0,0 +1,126 @@ +@isTest +public with sharing class ortoo_Asserts +{ + /** + * Assert that the actualString contains the expectedString + * + * Provided as this is a common assertion case, and usually requires the building + * of an assertion message for clarity when the assertion fails. + * + * @param String - The string to search for (expected) + * @param String - The string to search within (actual) + * @param String - The assertion message + */ + public static void assertContains( String expectedString, String actualString, String assertionMessage ) + { + if ( actualString == null && expectedString != null ) + { + System.assert(false, assertionMessage + ' (looking for: ' + expectedString + ', got: ' + actualString + ')' ); + } + System.assert( actualString.contains( expectedString ), assertionMessage + ' (looking for: ' + expectedString + ', got: ' + actualString + ')' ); + } + + /** + * Assert that the actualString does not contain the expectedString + * + * Provided as this is a common assertion case, and usually requires the building + * of an assertion message for clarity when the assertion fails. + * + * @param String - The string to search for (expected) + * @param String - The string to search within (actual) + * @param String - The assertion message + */ + public static void assertDoesNotContain( String expectedString, String actualString, String assertionMessage ) + { + System.assert( ! actualString.contains( expectedString ), assertionMessage + ' (making sure does not contain: ' + expectedString + ', got: ' + actualString + ')' ); + } + + /** + * Assert that the listOfStrings contains the expectedString + * + * Provided as this is a common assertion case, and usually requires the building + * of an assertion message for clarity when the assertion fails. + * + * @param String - The string to search for (expected) + * @param List - The list of strings to search within (actual) + * @param String - The assertion message + */ + public static void assertContains( String expectedString, List listOfStrings, String assertionMessage ) + { + if ( listOfStrings == null && expectedString != null ) + { + System.assert(false, assertionMessage + ' (looking for: ' + expectedString + ' in the List, got: ' + listOfStrings + ' List)' ); + } + System.assert( listOfStrings.contains( expectedString ), assertionMessage + ' (looking for: ' + expectedString + ' in the List, got: ' + listOfStrings + ' List)' ); + } + + /** + * Assert that the listOfStrings does not contain the expectedString + * + * Provided as this is a common assertion case, and usually requires the building + * of an assertion message for clarity when the assertion fails. + * + * @param String - The string to search for (expected) + * @param List - The list of strings to search within (actual) + * @param String - The assertion message + */ + public static void assertDoesNotContain( String expectedString, List listOfStrings, String assertionMessage ) + { + System.assert( ! listOfStrings.contains( expectedString ), assertionMessage + ' (making sure does not contain: ' + expectedString + ', got: ' + listOfStrings + ')' ); + } + + /** + * Assert that the actualString ends with the expectedString + * + * Provided as this is a common assertion case, and usually requires the building + * of an assertion message for clarity when the assertion fails. + * + * @param String - The string to search for (expected) + * @param String - The string to search within (actual) + * @param String - The assertion message + */ + public static void assertEndsWith( String expectedString, String actualString, String assertionMessage ) + { + if ( actualString == null && expectedString != null ) + { + System.assert(false, assertionMessage + ' (looking for ending with: ' + expectedString + ', got: ' + actualString + ')' ); + } + System.assert( actualString.endsWith( expectedString ), assertionMessage + ' (looking for ending with: ' + expectedString + ', got: ' + actualString + ')' ); + } + + /** + * Assert that the actualString starts with with the expectedString + * + * Provided as this is a common assertion case, and usually requires the building + * of an assertion message for clarity when the assertion fails. + * + * @param String - The string to search for (expected) + * @param String - The string to search within (actual) + * @param String - The assertion message + */ + public static void assertStartsWith( String expectedString, String actualString, String assertionMessage ) + { + if ( actualString == null && expectedString != null ) + { + System.assert(false, assertionMessage + ' (looking for starting with: ' + expectedString + ', got: ' + actualString + ')' ); + } + System.assert( actualString.startsWith( expectedString ), assertionMessage + ' (looking for starting with: ' + expectedString + ', got: ' + actualString + ')' ); + } + + /** + * Assert that the actual date is between the earliestExpected and latestExpected + * + * Provided as this is a common assertion case, and usually requires the building + * of an assertion message for clarity when the assertion fails. + * + * @param Date - The earliest date that is expected + * @param Date - The latest date that is expected + * @param Date - The actual date to check + * @param String - The assertion message + */ + public static void assertBetweenInclusive( Date earliestExpected, Date latestExpected, Date actual, String assertionMessage ) + { + Boolean inRange = actual >= earliestExpected && actual <= latestExpected; + System.assert( inRange, assertionMessage + ' (looking for ' + earliestExpected + ' to ' + latestExpected + ', got ' + actual + ')' ); + } +} diff --git a/framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls-meta.xml b/framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls-meta.xml new file mode 100644 index 00000000000..dd61d1f917e --- /dev/null +++ b/framework/default/ortoo-core/default/classes/test-utils/ortoo_Asserts.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/framework/default/ortoo-core/default/classes/tests/ApplicationTest.cls b/framework/default/ortoo-core/default/classes/tests/ApplicationTest.cls index c29ae27a8bb..5de24df91a7 100644 --- a/framework/default/ortoo-core/default/classes/tests/ApplicationTest.cls +++ b/framework/default/ortoo-core/default/classes/tests/ApplicationTest.cls @@ -225,7 +225,7 @@ private without sharing class ApplicationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Configuration exists with an invalid type (InvalidType)', exceptionMessage, 'applyConfiguration, when a record has an invalid type, will throw an exception' ); + ortoo_Asserts.assertContains( 'Configuration exists with an invalid type (InvalidType)', exceptionMessage, 'applyConfiguration, when a record has an invalid type, will throw an exception' ); } @isTest @@ -253,7 +253,7 @@ private without sharing class ApplicationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Configuration exists with an invalid sObject (InvalidSobject)', exceptionMessage, 'applyConfiguration, when a record has an invalid Sobject, will throw an exception' ); + ortoo_Asserts.assertContains( 'Configuration exists with an invalid sObject (InvalidSobject)', exceptionMessage, 'applyConfiguration, when a record has an invalid Sobject, will throw an exception' ); } @isTest @@ -281,7 +281,7 @@ private without sharing class ApplicationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Configuration exists with an invalid class (ApplicationTest.InvalidClass)', exceptionMessage, 'applyConfiguration, when a record has an invalid class, will throw an exception' ); + ortoo_Asserts.assertContains( 'Configuration exists with an invalid class (ApplicationTest.InvalidClass)', exceptionMessage, 'applyConfiguration, when a record has an invalid class, will throw an exception' ); } public interface IServiceInterface{} diff --git a/framework/default/ortoo-core/default/classes/tests/ProcessDeactivationTest.cls b/framework/default/ortoo-core/default/classes/tests/ProcessDeactivationTest.cls index 3522983e1d9..e8328535041 100644 --- a/framework/default/ortoo-core/default/classes/tests/ProcessDeactivationTest.cls +++ b/framework/default/ortoo-core/default/classes/tests/ProcessDeactivationTest.cls @@ -84,6 +84,6 @@ private without sharing class ProcessDeactivationTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'triggersDeactivated called with a null domainType', exceptionMessage, 'triggersDeactivated, when passed a null domainType, will throw an exception' ); + ortoo_Asserts.assertContains( 'triggersDeactivated called with a null domainType', exceptionMessage, 'triggersDeactivated, when passed a null domainType, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/utils/tests/ContractTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/ContractTest.cls index 5c8e9f90c24..8ccc4f673b8 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/ContractTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/ContractTest.cls @@ -23,7 +23,7 @@ private without sharing class ContractTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Contract.requires failed: will throw', exceptionThrown.getMessage(), 'requires, when given a false condition, will throw an exception' ); + ortoo_Asserts.assertContains( 'Contract.requires failed: will throw', exceptionThrown.getMessage(), 'requires, when given a false condition, will throw an exception' ); System.assertEquals( 'requires_whenGivenAFalseCondition_willThrowAnException', exceptionThrown.getStackTrace().getInnermostMethodName(), 'requires, when given a false condition, will throw an exception with the stack trace set to the caller' ); } @@ -49,7 +49,7 @@ private without sharing class ContractTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Contract.ensures failed: will throw', exceptionThrown.getMessage(), 'ensures, when given a false condition, will throw an exception' ); + ortoo_Asserts.assertContains( 'Contract.ensures failed: will throw', exceptionThrown.getMessage(), 'ensures, when given a false condition, will throw an exception' ); System.assertEquals( 'ensures_whenGivenAFalseCondition_willThrowAnException', exceptionThrown.getStackTrace().getInnermostMethodName(), 'ensures, when given a false condition, will throw an exception with the stack trace set to the caller' ); } @@ -75,7 +75,7 @@ private without sharing class ContractTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Contract.assert failed: will throw', exceptionThrown.getMessage(), 'assert, when given a false condition, will throw an exception' ); + ortoo_Asserts.assertContains( 'Contract.assert failed: will throw', exceptionThrown.getMessage(), 'assert, when given a false condition, will throw an exception' ); System.assertEquals( 'assert_whenGivenAFalseCondition_willThrowAnException', exceptionThrown.getStackTrace().getInnermostMethodName(), 'assert, when given a false condition, will throw an exception with the stack trace set to the caller' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/utils/tests/DirectedGraphTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/DirectedGraphTest.cls index 3dad7d1becc..74ce60b9086 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/DirectedGraphTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/DirectedGraphTest.cls @@ -139,7 +139,7 @@ private without sharing class DirectedGraphTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'The graph contains a circular reference and therefore cannot be resolved', exceptionMessage, 'generateSorted, when a circular reference has been defined, will throw an exception' ); + ortoo_Asserts.assertContains( 'The graph contains a circular reference and therefore cannot be resolved', exceptionMessage, 'generateSorted, when a circular reference has been defined, will throw an exception' ); } @isTest @@ -159,7 +159,7 @@ private without sharing class DirectedGraphTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addRelationship called with a child that has not been added as a node (UnregisteredChild)', exceptionMessage, 'addRelationship, when given a child that has not previously been added, will throw an exception' ); + ortoo_Asserts.assertContains( 'addRelationship called with a child that has not been added as a node (UnregisteredChild)', exceptionMessage, 'addRelationship, when given a child that has not previously been added, will throw an exception' ); } @isTest @@ -179,6 +179,6 @@ private without sharing class DirectedGraphTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addRelationship called with a parent that has not been added as a node (UnregisteredParent)', exceptionMessage, 'addRelationship, when given a parent that has not previously been added, will throw an exception' ); + ortoo_Asserts.assertContains( 'addRelationship called with a parent that has not been added as a node (UnregisteredParent)', exceptionMessage, 'addRelationship, when given a parent that has not previously been added, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/utils/tests/ListUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/ListUtilsTest.cls index 4d4a1019c3a..9dc52c2313c 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/ListUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/ListUtilsTest.cls @@ -181,7 +181,7 @@ private without sharing class ListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'slice called with a null list', exceptionMessage, 'slice, when given a null list, will throw an exception' ); + ortoo_Asserts.assertContains( 'slice called with a null list', exceptionMessage, 'slice, when given a null list, will throw an exception' ); } @isTest @@ -196,7 +196,7 @@ private without sharing class ListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'slice called with a null startElement', exceptionMessage, 'slice, when given a null start, will throw an exception' ); + ortoo_Asserts.assertContains( 'slice called with a null startElement', exceptionMessage, 'slice, when given a null start, will throw an exception' ); } @isTest @@ -211,7 +211,7 @@ private without sharing class ListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'slice called with a null endElement', exceptionMessage, 'slice, when given a null end, will throw an exception' ); + ortoo_Asserts.assertContains( 'slice called with a null endElement', exceptionMessage, 'slice, when given a null end, will throw an exception' ); } @isTest @@ -270,7 +270,7 @@ private without sharing class ListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'trim called with a null list', exceptionMessage, 'trim, when given a null list, will throw an exception' ); + ortoo_Asserts.assertContains( 'trim called with a null list', exceptionMessage, 'trim, when given a null list, will throw an exception' ); } @isTest @@ -285,7 +285,7 @@ private without sharing class ListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'trim called with a null length', exceptionMessage, 'trim, when given a null length, will throw an exception' ); + ortoo_Asserts.assertContains( 'trim called with a null length', exceptionMessage, 'trim, when given a null length, will throw an exception' ); } @isTest @@ -377,7 +377,7 @@ private without sharing class ListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'getNumberOfUniqueIds called with a null listOfSobjects', exceptionMessage, 'getNumberOfUniqueIds, when given a null list, will throw an exception' ); + ortoo_Asserts.assertContains( 'getNumberOfUniqueIds called with a null listOfSobjects', exceptionMessage, 'getNumberOfUniqueIds, when given a null list, will throw an exception' ); } @isTest @@ -396,7 +396,7 @@ private without sharing class ListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'getNumberOfUniqueIds called with a null idField', exceptionMessage, 'getNumberOfUniqueIds, when given a null id field, will throw an exception' ); + ortoo_Asserts.assertContains( 'getNumberOfUniqueIds called with a null idField', exceptionMessage, 'getNumberOfUniqueIds, when given a null id field, will throw an exception' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/utils/tests/MapUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/MapUtilsTest.cls index 600e3f28f88..5cc940df13d 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/MapUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/MapUtilsTest.cls @@ -63,7 +63,7 @@ private without sharing class MapUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( '', exceptionMessage, 'remove, when given a null map, will throw an exception' ); + ortoo_Asserts.assertContains( '', exceptionMessage, 'remove, when given a null map, will throw an exception' ); } /** diff --git a/framework/default/ortoo-core/default/classes/utils/tests/PackageUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/PackageUtilsTest.cls index 2681d2e381f..7c10b235d3c 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/PackageUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/PackageUtilsTest.cls @@ -49,7 +49,7 @@ private without sharing class PackageUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getNamespace was called with a null classType', exceptionMessage, 'getNamespace, when called with a null object, will throw an exception' ); + ortoo_Asserts.assertContains( 'getNamespace was called with a null classType', exceptionMessage, 'getNamespace, when called with a null object, will throw an exception' ); } @isTest diff --git a/framework/default/ortoo-core/default/classes/utils/tests/PrivateObjectUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/PrivateObjectUtilsTest.cls index d04773d1b13..3b531375069 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/PrivateObjectUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/PrivateObjectUtilsTest.cls @@ -39,7 +39,7 @@ private without sharing class PrivateObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getClassType was unable to determine the type for the object. Most likely it is private.', thrownException.getMessage(), 'getClassType, when given an instance of a private class, will throw an exception' ); + ortoo_Asserts.assertContains( 'getClassType was unable to determine the type for the object. Most likely it is private.', thrownException.getMessage(), 'getClassType, when given an instance of a private class, will throw an exception' ); System.assertEquals( privateObject, thrownException.getContexts().next().getValue(), 'getClassType, when given an instance of a private class, will throw an exception with the object as a context property' ); } @@ -67,7 +67,7 @@ private without sharing class PrivateObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getClassType was unable to determine the type for the object. Most likely it is private.', thrownException.getMessage(), 'getClassType,when given an instance of a private inner class of a private class, will throw an exception' ); + ortoo_Asserts.assertContains( 'getClassType was unable to determine the type for the object. Most likely it is private.', thrownException.getMessage(), 'getClassType,when given an instance of a private inner class of a private class, will throw an exception' ); System.assertEquals( privateObject, thrownException.getContexts().next().getValue(), 'getClassType, when given an instance of a private inner class of a private class, will throw an exception with the object as a context property' ); } @@ -86,7 +86,7 @@ private without sharing class PrivateObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); + ortoo_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); } @isTest @@ -104,7 +104,7 @@ private without sharing class PrivateObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); + ortoo_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); } @isTest @@ -122,7 +122,7 @@ private without sharing class PrivateObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); + ortoo_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); } public class PublicInnerClass {} diff --git a/framework/default/ortoo-core/default/classes/utils/tests/PublicObjectUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/PublicObjectUtilsTest.cls index 28684df1f65..4f6040a3fc6 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/PublicObjectUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/PublicObjectUtilsTest.cls @@ -51,7 +51,7 @@ public without sharing class PublicObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getClassName called with a null obj', exceptionMessage, 'getClassName, when called with a null object, will throw an exception' ); + ortoo_Asserts.assertContains( 'getClassName called with a null obj', exceptionMessage, 'getClassName, when called with a null object, will throw an exception' ); } @isTest @@ -85,7 +85,7 @@ public without sharing class PublicObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getClassType was unable to determine the type for the object. Most likely it is private.', thrownException.getMessage(), 'getClassType, when called with a private inner class of a public class, will throw an exception' ); + ortoo_Asserts.assertContains( 'getClassType was unable to determine the type for the object. Most likely it is private.', thrownException.getMessage(), 'getClassType, when called with a private inner class of a public class, will throw an exception' ); System.assertEquals( privateObject, thrownException.getContexts().next().getValue(), 'getClassType, when called with a private inner class of a public class, will throw an exception with the object as a context property' ); } @@ -104,7 +104,7 @@ public without sharing class PublicObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getClassType called with a null obj', exceptionMessage, 'getClassType, when called with a null object, will throw an exception' ); + ortoo_Asserts.assertContains( 'getClassType called with a null obj', exceptionMessage, 'getClassType, when called with a null object, will throw an exception' ); } @isTest @@ -122,7 +122,7 @@ public without sharing class PublicObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); + ortoo_Asserts.assertContains( 'getParentClassType called with a type that does not represent an inner class in a publically accessible class', exceptionMessage, 'getParentClassType, when given a type for a top level class, will throw an exception' ); } @isTest @@ -140,7 +140,7 @@ public without sharing class PublicObjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getParentClassType called with a null innerClassType', exceptionMessage, 'getParentClassType, when called with a null object, will throw an exception' ); + ortoo_Asserts.assertContains( 'getParentClassType called with a null innerClassType', exceptionMessage, 'getParentClassType, when called with a null object, will throw an exception' ); } public class PublicInnerClass {} diff --git a/framework/default/ortoo-core/default/classes/utils/tests/SelectOptionListUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/SelectOptionListUtilsTest.cls index 77b31d1aed8..aae5a25fd47 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/SelectOptionListUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/SelectOptionListUtilsTest.cls @@ -71,6 +71,6 @@ private without sharing class SelectOptionListUtilsTest exceptionMessage = e.getMessage(); } - Amoss_Asserts.assertContains( 'trimToManageableLength called with a null List', exceptionMessage, 'trimToManageableLength, when given a null list, will throw an exception' ); + ortoo_Asserts.assertContains( 'trimToManageableLength called with a null List', exceptionMessage, 'trimToManageableLength, when given a null list, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/utils/tests/SobjectUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/SobjectUtilsTest.cls index d3d958118a7..8d4595249f6 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/SobjectUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/SobjectUtilsTest.cls @@ -39,7 +39,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Attempted to get the name of a null SObject', exceptionMessage, 'getSobjectType, when given a null Sobject, will throw an exception' ); + ortoo_Asserts.assertContains( 'Attempted to get the name of a null SObject', exceptionMessage, 'getSobjectType, when given a null Sobject, will throw an exception' ); } @isTest @@ -79,7 +79,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'getSobjectType called with a null record', exceptionMessage, 'getSobjectType, when passed a null record, will throw an exception' ); + ortoo_Asserts.assertContains( 'getSobjectType called with a null record', exceptionMessage, 'getSobjectType, when passed a null record, will throw an exception' ); } @isTest @@ -106,7 +106,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Attempted to get the name of a null SObject', exceptionMessage, 'getSobjectName, when given a null Sobject, will throw an exception' ); + ortoo_Asserts.assertContains( 'Attempted to get the name of a null SObject', exceptionMessage, 'getSobjectName, when given a null Sobject, will throw an exception' ); } @isTest @@ -133,7 +133,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'Attempted to get the name of a null SObjectType', exceptionMessage, 'getSobjectName, when given a null SobjectType, will throw an exception' ); + ortoo_Asserts.assertContains( 'Attempted to get the name of a null SObjectType', exceptionMessage, 'getSobjectName, when given a null SobjectType, will throw an exception' ); } @isTest @@ -164,7 +164,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isCreateable called with a null record', exceptionMessage, 'isCreateable, when given a null record, will throw an exception' ); + ortoo_Asserts.assertContains( 'isCreateable called with a null record', exceptionMessage, 'isCreateable, when given a null record, will throw an exception' ); } @isTest @@ -195,7 +195,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isUpdateable called with a null record', exceptionMessage, 'isUpdateable, when given a null record, will throw an exception' ); + ortoo_Asserts.assertContains( 'isUpdateable called with a null record', exceptionMessage, 'isUpdateable, when given a null record, will throw an exception' ); } @isTest @@ -226,7 +226,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isDeletable called with a null record', exceptionMessage, 'isDeletable, when given a null record, will throw an exception' ); + ortoo_Asserts.assertContains( 'isDeletable called with a null record', exceptionMessage, 'isDeletable, when given a null record, will throw an exception' ); } @isTest @@ -255,7 +255,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isCreateable called with a null type', exceptionMessage, 'isCreateable, when given a null SObjectType, will throw an exception' ); + ortoo_Asserts.assertContains( 'isCreateable called with a null type', exceptionMessage, 'isCreateable, when given a null SObjectType, will throw an exception' ); } @isTest @@ -284,7 +284,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isUpdateable called with a null type', exceptionMessage, 'isUpdateable, when given a null SObjectType, will throw an exception' ); + ortoo_Asserts.assertContains( 'isUpdateable called with a null type', exceptionMessage, 'isUpdateable, when given a null SObjectType, will throw an exception' ); } @isTest @@ -313,7 +313,7 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isDeletable called with a null type', exceptionMessage, 'isDeletable, when given a null SObjectType, will throw an exception' ); + ortoo_Asserts.assertContains( 'isDeletable called with a null type', exceptionMessage, 'isDeletable, when given a null SObjectType, will throw an exception' ); } @isTest @@ -342,6 +342,6 @@ private without sharing class SobjectUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'isAccessible called with a null type', exceptionMessage, 'isAccessible, when given a null SObjectType, will throw an exception' ); + ortoo_Asserts.assertContains( 'isAccessible called with a null type', exceptionMessage, 'isAccessible, when given a null SObjectType, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/utils/tests/StringUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/StringUtilsTest.cls index bfb41ffba1d..6bb167deb21 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/StringUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/StringUtilsTest.cls @@ -165,7 +165,7 @@ private without sharing class StringUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'convertDelimitedStringToList called with an empty delimiter', exceptionMessage, 'convertDelimitedStringToList, when passed a null delimiter, will throw an exception' ); + ortoo_Asserts.assertContains( 'convertDelimitedStringToList called with an empty delimiter', exceptionMessage, 'convertDelimitedStringToList, when passed a null delimiter, will throw an exception' ); } @isTest @@ -183,7 +183,7 @@ private without sharing class StringUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'convertDelimitedStringToList called with an empty delimiter', exceptionMessage, 'convertDelimitedStringToList, when passed an empty delimiter, will throw an exception' ); + ortoo_Asserts.assertContains( 'convertDelimitedStringToList called with an empty delimiter', exceptionMessage, 'convertDelimitedStringToList, when passed an empty delimiter, will throw an exception' ); } @isTest @@ -242,7 +242,7 @@ private without sharing class StringUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'convertListToDelimitedString called with a null listOfStrings', exceptionMessage, 'convertListToDelimitedString, when passed a null listOfStrings, will throw an exception' ); + ortoo_Asserts.assertContains( 'convertListToDelimitedString called with a null listOfStrings', exceptionMessage, 'convertListToDelimitedString, when passed a null listOfStrings, will throw an exception' ); } @isTest @@ -288,7 +288,7 @@ private without sharing class StringUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'convertListToDelimitedString called with a null listOfObjects', exceptionMessage, 'convertListToDelimitedString, when passed a null listOfObjects, will throw an exception' ); + ortoo_Asserts.assertContains( 'convertListToDelimitedString called with a null listOfObjects', exceptionMessage, 'convertListToDelimitedString, when passed a null listOfObjects, will throw an exception' ); } @isTest @@ -334,7 +334,7 @@ private without sharing class StringUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'convertListToDelimitedString called with a null listOfObjects', exceptionMessage, 'convertListToDelimitedString, when passed a null listOfObjects and a delimiter, will throw an exception' ); + ortoo_Asserts.assertContains( 'convertListToDelimitedString called with a null listOfObjects', exceptionMessage, 'convertListToDelimitedString, when passed a null listOfObjects and a delimiter, will throw an exception' ); } @isTest @@ -354,7 +354,7 @@ private without sharing class StringUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'convertListToDelimitedString called with an empty delimiter', exceptionMessage, 'convertListToDelimitedString, when passed a null delimiter, will throw an exception' ); + ortoo_Asserts.assertContains( 'convertListToDelimitedString called with an empty delimiter', exceptionMessage, 'convertListToDelimitedString, when passed a null delimiter, will throw an exception' ); } @isTest @@ -374,7 +374,7 @@ private without sharing class StringUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'convertListToDelimitedString called with an empty delimiter', exceptionMessage, 'convertListToDelimitedString, when passed an empty delimiter, will throw an exception' ); + ortoo_Asserts.assertContains( 'convertListToDelimitedString called with an empty delimiter', exceptionMessage, 'convertListToDelimitedString, when passed an empty delimiter, will throw an exception' ); } private inherited sharing class StringableThing { diff --git a/framework/default/ortoo-core/default/classes/utils/tests/UriUtilsTest.cls b/framework/default/ortoo-core/default/classes/utils/tests/UriUtilsTest.cls index 704c287f2d6..3605a6b2dc2 100644 --- a/framework/default/ortoo-core/default/classes/utils/tests/UriUtilsTest.cls +++ b/framework/default/ortoo-core/default/classes/utils/tests/UriUtilsTest.cls @@ -177,7 +177,7 @@ private without sharing class UriUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'buildUriFragment called with a null properties', exceptionMessage, 'buildUriFragment, when passed a null properties, will throw an exception' ); + ortoo_Asserts.assertContains( 'buildUriFragment called with a null properties', exceptionMessage, 'buildUriFragment, when passed a null properties, will throw an exception' ); } @isTest @@ -215,7 +215,7 @@ private without sharing class UriUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addUriFragment called with a null pageReference', exceptionMessage, 'addUriFragment, when passed a null pageReference, will throw an exception' ); + ortoo_Asserts.assertContains( 'addUriFragment called with a null pageReference', exceptionMessage, 'addUriFragment, when passed a null pageReference, will throw an exception' ); } @isTest @@ -233,6 +233,6 @@ private without sharing class UriUtilsTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'addUriFragment called with a null properties', exceptionMessage, 'addUriFragment, when passed a null properties, will throw an exception' ); + ortoo_Asserts.assertContains( 'addUriFragment called with a null properties', exceptionMessage, 'addUriFragment, when passed a null properties, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/validators/tests/SobjectListValidatorTest.cls b/framework/default/ortoo-core/default/classes/validators/tests/SobjectListValidatorTest.cls index 688e0601a15..311fd5ce36f 100644 --- a/framework/default/ortoo-core/default/classes/validators/tests/SobjectListValidatorTest.cls +++ b/framework/default/ortoo-core/default/classes/validators/tests/SobjectListValidatorTest.cls @@ -61,6 +61,6 @@ private without sharing class SobjectListValidatorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'SobjectListValidator instantiated with a null records', exceptionMessage, 'constructor, when passed a null records, will throw an exception' ); + ortoo_Asserts.assertContains( 'SobjectListValidator instantiated with a null records', exceptionMessage, 'constructor, when passed a null records, will throw an exception' ); } } \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/validators/tests/SobjectValidatorTest.cls b/framework/default/ortoo-core/default/classes/validators/tests/SobjectValidatorTest.cls index 770e1ebcf3b..a3cc895e0b9 100644 --- a/framework/default/ortoo-core/default/classes/validators/tests/SobjectValidatorTest.cls +++ b/framework/default/ortoo-core/default/classes/validators/tests/SobjectValidatorTest.cls @@ -32,7 +32,7 @@ private without sharing class SobjectValidatorTest } Test.stopTest(); - Amoss_Asserts.assertContains( 'setSobject called with a null sobjectToValidate', exceptionMessage, 'setSobject, when passed null, will throw an exception' ); + ortoo_Asserts.assertContains( 'setSobject called with a null sobjectToValidate', exceptionMessage, 'setSobject, when passed null, will throw an exception' ); } private without sharing class TestableSobjectValidator extends SobjectValidator diff --git a/framework/default/ortoo-lwc-list-view-buttons/classes/tests/AbstractRedirectToLwcTabControllerTest.cls b/framework/default/ortoo-lwc-list-view-buttons/classes/tests/AbstractRedirectToLwcTabControllerTest.cls index b821aa24070..206e8dc00bb 100644 --- a/framework/default/ortoo-lwc-list-view-buttons/classes/tests/AbstractRedirectToLwcTabControllerTest.cls +++ b/framework/default/ortoo-lwc-list-view-buttons/classes/tests/AbstractRedirectToLwcTabControllerTest.cls @@ -60,7 +60,7 @@ public with sharing class AbstractRedirectToLwcTabControllerTest PageReference got = controller.redirectToTab(); Test.stopTest(); - Amoss_Asserts.assertContains( 'tabName', got.getUrl(), 'redirectToTab, when called, will retrun a PageReference with the URL pointing to the defined tab page' ); + ortoo_Asserts.assertContains( 'tabName', got.getUrl(), 'redirectToTab, when called, will retrun a PageReference with the URL pointing to the defined tab page' ); Map parameters = got.getParameters(); System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTab, when called, will return a PageReference with a return url parameter' ); @@ -87,7 +87,7 @@ public with sharing class AbstractRedirectToLwcTabControllerTest PageReference got = controller.redirectToTab(); Test.stopTest(); - Amoss_Asserts.assertContains( 'tabName', got.getUrl(), 'redirectToTab, when no records are selected, will retrun a PageReference with the URL pointing to the defined tab page' ); + ortoo_Asserts.assertContains( 'tabName', got.getUrl(), 'redirectToTab, when no records are selected, will retrun a PageReference with the URL pointing to the defined tab page' ); Map parameters = got.getParameters(); System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTab, when no records are selected, will return a PageReference with a return url parameter' ); From ac74a5f1fcdd2539e4a1315448bbb4c8d62dd1fe Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 12:14:00 +0000 Subject: [PATCH 07/17] Started a date literals test --- .../tests/ortoo_DateLiteralsTest.cls | 68 +++++++++++++++++++ .../tests/ortoo_DateLiteralsTest.cls-meta.xml | 5 ++ 2 files changed, 73 insertions(+) create mode 100644 framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls create mode 100644 framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls-meta.xml diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls new file mode 100644 index 00000000000..0b421c90158 --- /dev/null +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -0,0 +1,68 @@ +@isTest +private without sharing class ortoo_DateLiteralsTest +{ + @isTest + private static void today_whenReferenced_returnsTodaysDate() // NOPMD: Test method name format + { + Date got = ortoo_DateLiterals.today; + System.assertEquals( Date.today(), got, 'today, when referenced, is set to today' ); + } + + @isTest + private static void yesterday_whenReferenced_returnYesterdayBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 01 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.yesterday; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'yesterday, when referenced, is set to yesterday, based on the configured "today"' ); + } + + @isTest + private static void tomorrow_whenReferenced_returnTomorrowBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.tomorrow; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 03, 01 ), got, 'tomorrow, when referenced, is set to tomorrow, based on the configured "today"' ); + } + + @isTest + private static void startOfThisWeek_whenReferenced_returnsStartOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfThisWeek; + Test.stopTest(); + + Date expectedEarliest = Date.newInstance( 2024, 02, 25 ); + Date expectedLatest = Date.newInstance( 2024, 02, 26 ); + + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfThisWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' ); + } + + @isTest + private static void endOfThisWeek_whenReferenced_returnsEndOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfThisWeek; + Test.stopTest(); + + Date expectedEarliest = Date.newInstance( 2024, 03, 02 ); + Date expectedLatest = Date.newInstance( 2024, 03, 03 ); + + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek, when referenced, is set to the stendart of this week, based on the configured "today" and the current user locale' ); + } + + + + +} \ No newline at end of file diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls-meta.xml b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls-meta.xml new file mode 100644 index 00000000000..dd61d1f917e --- /dev/null +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + From 9c674fb4fc0e540f998849873622a9a6a4748158 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 12:58:51 +0000 Subject: [PATCH 08/17] Added more dateLiteral tests (this and next week) --- .../tests/ortoo_DateLiteralsTest.cls | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index 0b421c90158..cd1953ad8c4 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -59,10 +59,92 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 03, 02 ); Date expectedLatest = Date.newInstance( 2024, 03, 03 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek, when referenced, is set to the stendart of this week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' ); } + @isTest + private static void startOfLastWeek_whenReferenced_returnsStartOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfLastWeek; + Test.stopTest(); + + Date expectedEarliest = Date.newInstance( 2024, 02, 18 ); + Date expectedLatest = Date.newInstance( 2024, 02, 19 ); + + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfLastWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' ); + } + + @isTest + private static void endOfLastWeek_whenReferenced_returnsEndOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfLastWeek; + Test.stopTest(); + + Date expectedEarliest = Date.newInstance( 2024, 02, 24 ); + Date expectedLatest = Date.newInstance( 2024, 02, 25 ); + + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfLastWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' ); + } + + @isTest + private static void endOfLastWeek_whenReferenced_returnsTheDayBeforeTheStartOfThisWeek() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfLastWeek; + Test.stopTest(); + + System.assertEquals( ortoo_DateLiterals.startOfThisWeek.addDays( -1 ), got, 'endOfLastWeek, is set to the day before startOfThisWeek' ); + } + @isTest + private static void startOfNextWeek_whenReferenced_returnsStartOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfNextWeek; + Test.stopTest(); + + Date expectedEarliest = Date.newInstance( 2024, 03, 03 ); + Date expectedLatest = Date.newInstance( 2024, 03, 04 ); + + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfNextWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' ); + } + + @isTest + private static void endOfNextWeek_whenReferenced_returnsEndOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfNextWeek; + Test.stopTest(); + + Date expectedEarliest = Date.newInstance( 2024, 03, 09 ); + Date expectedLatest = Date.newInstance( 2024, 03, 10 ); + + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfNextWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' ); + } + + @isTest + private static void startOfNextWeek_whenReferenced_returnsTheDayAfterTheEndOfThisWeek() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfNextWeek; + Test.stopTest(); + + System.assertEquals( ortoo_DateLiterals.endOfThisWeek.addDays( 1 ), got, 'startOfNextWeek, is set to the day after endOfThisWeek' ); + } } \ No newline at end of file From 98500460b8edc6ee0ea53786eb13239e65f2af4f Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 13:11:10 +0000 Subject: [PATCH 09/17] More tests on date literals - covering months --- .../fflib-extension/ortoo_DateLiterals.cls | 2 +- .../tests/ortoo_DateLiteralsTest.cls | 107 +++++++++++++++++- 2 files changed, 104 insertions(+), 5 deletions(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index 94f99867d38..ee7c0d9a98b 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -149,7 +149,7 @@ public inherited sharing class ortoo_DateLiterals { get { - return startOfThisMonth.addMonths( 1 ).addDays( -1 ); // Note, do not change to endOfThisMonth.addMonths, as this can switch months + return startOfThisMonth.addMonths( 2 ).addDays( -1 ); // Note, do not change to endOfThisMonth.addMonths, as this can switch months } } diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index cd1953ad8c4..74596269387 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -1,6 +1,9 @@ + @isTest private without sharing class ortoo_DateLiteralsTest { + // TODO: start of and end of this, on the day that is already start or end + @isTest private static void today_whenReferenced_returnsTodaysDate() // NOPMD: Test method name format { @@ -74,7 +77,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 02, 18 ); Date expectedLatest = Date.newInstance( 2024, 02, 19 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfLastWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfLastWeek, when referenced, is set to the start of last week, based on the configured "today" and the current user locale' ); } @isTest @@ -89,7 +92,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 02, 24 ); Date expectedLatest = Date.newInstance( 2024, 02, 25 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfLastWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfLastWeek, when referenced, is set to the end of last week, based on the configured "today" and the current user locale' ); } @isTest @@ -117,7 +120,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 03, 03 ); Date expectedLatest = Date.newInstance( 2024, 03, 04 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfNextWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfNextWeek, when referenced, is set to the start of next week, based on the configured "today" and the current user locale' ); } @isTest @@ -132,7 +135,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 03, 09 ); Date expectedLatest = Date.newInstance( 2024, 03, 10 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfNextWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfNextWeek, when referenced, is set to the end of next week, based on the configured "today" and the current user locale' ); } @isTest @@ -147,4 +150,100 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( ortoo_DateLiterals.endOfThisWeek.addDays( 1 ), got, 'startOfNextWeek, is set to the day after endOfThisWeek' ); } + @isTest + private static void startOfThisMonth_whenReferenced_returnsStartOfThisMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfThisMonth; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 02, 01 ), got, 'startOfThisMonth, is set to the start of this month, based on the configured today' ); + } + + @isTest + private static void endOfThisMonth_whenReferenced_returnsEndOfThisMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 10 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfThisMonth; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'endOfThisMonth, is set to the end of this month' ); + } + + @isTest + private static void startOfLastMonth_whenReferenced_returnsStartOfLastMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 30 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfLastMonth; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 02, 01 ), got, 'startOfLastMonth, is set to the start of last month' ); + } + + @isTest + private static void endOfLastMonth_whenReferenced_returnsEndOfLastMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 30 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfLastMonth; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'endOfLastMonth, is set to the end of last month' ); + } + + @isTest + private static void endOfLastMonth_whenReferenced_returnsTheDayBeforeTheStartOfThisMonth() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 05 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfLastMonth; + Test.stopTest(); + + System.assertEquals( ortoo_DateLiterals.startOfThisMonth.addDays( -1 ), got, 'endOfLastMonth, is set to the day before startOfThisMonth' ); + } + + + @isTest + private static void startOfNextMonth_whenReferenced_returnsStartOfNextMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 01, 30 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfNextMonth; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 02, 01 ), got, 'endOfLastMonth, is set to the end of next month' ); + } + + @isTest + private static void endOfNextMonth_whenReferenced_returnsEndOfNextMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 01, 30 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfNextMonth; + Test.stopTest(); + + System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'endOfLastMonth, is set to the end of next month' ); + } + + @isTest + private static void startOfNextMonth_whenReferenced_returnsTheDayAfterTheEndOfThisMonth() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfNextMonth; + Test.stopTest(); + + System.assertEquals( ortoo_DateLiterals.endOfThisMonth.addDays( 1 ), got, 'startOfNextMonth, is set to the day after endOfThisMonth' ); + } } \ No newline at end of file From c0794aca9344bc26672b871e752798335a3bca51 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 13:18:05 +0000 Subject: [PATCH 10/17] Added some edge case tests --- .../tests/ortoo_DateLiteralsTest.cls | 72 ++++++++++++++++--- 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index 74596269387..a0fcc884f1a 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -2,13 +2,11 @@ @isTest private without sharing class ortoo_DateLiteralsTest { - // TODO: start of and end of this, on the day that is already start or end - @isTest private static void today_whenReferenced_returnsTodaysDate() // NOPMD: Test method name format { Date got = ortoo_DateLiterals.today; - System.assertEquals( Date.today(), got, 'today, when referenced, is set to today' ); + System.assertEquals( Date.today(), got, 'today is set to today' ); } @isTest @@ -20,7 +18,7 @@ private without sharing class ortoo_DateLiteralsTest Date got = ortoo_DateLiterals.yesterday; Test.stopTest(); - System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'yesterday, when referenced, is set to yesterday, based on the configured "today"' ); + System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'yesterday is set to yesterday, based on the configured "today"' ); } @isTest @@ -32,7 +30,7 @@ private without sharing class ortoo_DateLiteralsTest Date got = ortoo_DateLiterals.tomorrow; Test.stopTest(); - System.assertEquals( Date.newInstance( 2024, 03, 01 ), got, 'tomorrow, when referenced, is set to tomorrow, based on the configured "today"' ); + System.assertEquals( Date.newInstance( 2024, 03, 01 ), got, 'tomorrow is set to tomorrow, based on the configured "today"' ); } @isTest @@ -47,7 +45,20 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 02, 25 ); Date expectedLatest = Date.newInstance( 2024, 02, 26 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfThisWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfThisWeek is set to the start of this week, based on the configured "today" and the current user locale' ); + } + + @isTest + private static void startOfThisWeek_whenItIsTheStartOfTheWeek_returnsToday() // NOPMD: Test method name format + { + Date startOfThisWeek = ortoo_DateLiterals.startOfThisWeek; + ortoo_DateLiterals.today = startOfThisWeek; + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfThisWeek; + Test.stopTest(); + + System.assertEquals( startOfThisWeek, got, 'startOfThisWeek, when today is the start of the week, will return today' ); } @isTest @@ -62,7 +73,20 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 03, 02 ); Date expectedLatest = Date.newInstance( 2024, 03, 03 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek is set to the end of this week, based on the configured "today" and the current user locale' ); + } + + @isTest + private static void endOfThisWeek_whenItIsTheStartOfTheWeek_returnsToday() // NOPMD: Test method name format + { + Date endOfThisWeek = ortoo_DateLiterals.endOfThisWeek; + ortoo_DateLiterals.today = endOfThisWeek; + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfThisWeek; + Test.stopTest(); + + System.assertEquals( endOfThisWeek, got, 'endOfThisWeek, when today is the end of the week, will return today' ); } @isTest @@ -77,7 +101,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 02, 18 ); Date expectedLatest = Date.newInstance( 2024, 02, 19 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfLastWeek, when referenced, is set to the start of last week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfLastWeek is set to the start of last week, based on the configured "today" and the current user locale' ); } @isTest @@ -92,7 +116,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 02, 24 ); Date expectedLatest = Date.newInstance( 2024, 02, 25 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfLastWeek, when referenced, is set to the end of last week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfLastWeek is set to the end of last week, based on the configured "today" and the current user locale' ); } @isTest @@ -120,7 +144,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 03, 03 ); Date expectedLatest = Date.newInstance( 2024, 03, 04 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfNextWeek, when referenced, is set to the start of next week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfNextWeek is set to the start of next week, based on the configured "today" and the current user locale' ); } @isTest @@ -135,7 +159,7 @@ private without sharing class ortoo_DateLiteralsTest Date expectedEarliest = Date.newInstance( 2024, 03, 09 ); Date expectedLatest = Date.newInstance( 2024, 03, 10 ); - ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfNextWeek, when referenced, is set to the end of next week, based on the configured "today" and the current user locale' ); + ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfNextWeek is set to the end of next week, based on the configured "today" and the current user locale' ); } @isTest @@ -162,6 +186,19 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( Date.newInstance( 2024, 02, 01 ), got, 'startOfThisMonth, is set to the start of this month, based on the configured today' ); } + @isTest + private static void startOfThisMonth_whenItIsTheStartOfTheMonth_returnsToday() // NOPMD: Test method name format + { + Date startOfThisMonth = ortoo_DateLiterals.startOfThisMonth; + ortoo_DateLiterals.today = startOfThisMonth; + + Test.startTest(); + Date got = ortoo_DateLiterals.startOfThisMonth; + Test.stopTest(); + + System.assertEquals( startOfThisMonth, got, 'startOfThisMonth, when today is the start of the month, will return today' ); + } + @isTest private static void endOfThisMonth_whenReferenced_returnsEndOfThisMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { @@ -174,6 +211,19 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'endOfThisMonth, is set to the end of this month' ); } + @isTest + private static void endOfThisMonth_whenItIsTheStartOfTheMonth_returnsToday() // NOPMD: Test method name format + { + Date endOfThisMonth = ortoo_DateLiterals.endOfThisMonth; + ortoo_DateLiterals.today = endOfThisMonth; + + Test.startTest(); + Date got = ortoo_DateLiterals.endOfThisMonth; + Test.stopTest(); + + System.assertEquals( endOfThisMonth, got, 'endOfThisMonth, when today is the end of the month, will return today' ); + } + @isTest private static void startOfLastMonth_whenReferenced_returnsStartOfLastMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { From 796ca56a397c9f2e759a2a2dc19f130a583f40ee Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 13:26:19 +0000 Subject: [PATCH 11/17] Started to add tests for the comparables in date literals --- .../fflib-extension/ortoo_DateLiterals.cls | 8 +- .../tests/ortoo_DateLiteralsTest.cls | 74 ++++++++++++++----- 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index ee7c0d9a98b..bdfc6fa01c9 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -568,10 +568,14 @@ public inherited sharing class ortoo_DateLiterals } } + @testVisible private abstract class DateRangeLiteral implements ortoo_DateLiterals.Comparable { + @testVisible protected abstract String toLiteral(); + @testVisible protected abstract Date getStartDate(); + @testVisible protected abstract Date getEndDate(); public Integer compare( Object otherValue ) @@ -593,8 +597,8 @@ public inherited sharing class ortoo_DateLiterals private class DateTimeToDateRangeComparer { - public Integer compare( DateTime value, Date startDate, Date endDate ) { - + public Integer compare( DateTime value, Date startDate, Date endDate ) + { if ( value < DateTime.newInstance( startDate.year(), startDate.month(), startDate.day(), 0, 0, 0 ) ) { return -1; diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index a0fcc884f1a..754f1215939 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -3,14 +3,14 @@ private without sharing class ortoo_DateLiteralsTest { @isTest - private static void today_whenReferenced_returnsTodaysDate() // NOPMD: Test method name format + private static void today_returnsTodaysDate() // NOPMD: Test method name format { Date got = ortoo_DateLiterals.today; System.assertEquals( Date.today(), got, 'today is set to today' ); } @isTest - private static void yesterday_whenReferenced_returnYesterdayBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void yesterday_returnYesterdayBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 01 ); @@ -22,7 +22,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void tomorrow_whenReferenced_returnTomorrowBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void tomorrow_returnTomorrowBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -34,7 +34,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void startOfThisWeek_whenReferenced_returnsStartOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + private static void startOfThisWeek_returnsStartOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -62,7 +62,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfThisWeek_whenReferenced_returnsEndOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + private static void endOfThisWeek_returnsEndOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -90,7 +90,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void startOfLastWeek_whenReferenced_returnsStartOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + private static void startOfLastWeek_returnsStartOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -105,7 +105,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfLastWeek_whenReferenced_returnsEndOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + private static void endOfLastWeek_returnsEndOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -120,7 +120,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfLastWeek_whenReferenced_returnsTheDayBeforeTheStartOfThisWeek() // NOPMD: Test method name format + private static void endOfLastWeek_returnsTheDayBeforeTheStartOfThisWeek() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -133,7 +133,7 @@ private without sharing class ortoo_DateLiteralsTest @isTest - private static void startOfNextWeek_whenReferenced_returnsStartOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + private static void startOfNextWeek_returnsStartOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -148,7 +148,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfNextWeek_whenReferenced_returnsEndOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format + private static void endOfNextWeek_returnsEndOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -163,7 +163,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void startOfNextWeek_whenReferenced_returnsTheDayAfterTheEndOfThisWeek() // NOPMD: Test method name format + private static void startOfNextWeek_returnsTheDayAfterTheEndOfThisWeek() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -175,7 +175,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void startOfThisMonth_whenReferenced_returnsStartOfThisMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void startOfThisMonth_returnsStartOfThisMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -200,7 +200,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfThisMonth_whenReferenced_returnsEndOfThisMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void endOfThisMonth_returnsEndOfThisMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 10 ); @@ -225,7 +225,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void startOfLastMonth_whenReferenced_returnsStartOfLastMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void startOfLastMonth_returnsStartOfLastMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 30 ); @@ -237,7 +237,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfLastMonth_whenReferenced_returnsEndOfLastMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void endOfLastMonth_returnsEndOfLastMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 30 ); @@ -249,7 +249,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfLastMonth_whenReferenced_returnsTheDayBeforeTheStartOfThisMonth() // NOPMD: Test method name format + private static void endOfLastMonth_returnsTheDayBeforeTheStartOfThisMonth() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 05 ); @@ -262,7 +262,7 @@ private without sharing class ortoo_DateLiteralsTest @isTest - private static void startOfNextMonth_whenReferenced_returnsStartOfNextMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void startOfNextMonth_returnsStartOfNextMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 01, 30 ); @@ -274,7 +274,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void endOfNextMonth_whenReferenced_returnsEndOfNextMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format + private static void endOfNextMonth_returnsEndOfNextMonthBasedOnTheConfiguredToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 01, 30 ); @@ -286,7 +286,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void startOfNextMonth_whenReferenced_returnsTheDayAfterTheEndOfThisMonth() // NOPMD: Test method name format + private static void startOfNextMonth_returnsTheDayAfterTheEndOfThisMonth() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -296,4 +296,40 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( ortoo_DateLiterals.endOfThisMonth.addDays( 1 ), got, 'startOfNextMonth, is set to the day after endOfThisMonth' ); } + + @isTest + private static void Today_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.Today().toLiteral(); + System.assertEquals( 'TODAY', got, 'Today.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void Today_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.Today(); + + System.assertEquals( Date.newInstance( 2024, 02, 29 ), literal.getStartDate(), 'Today_getStartDate, will return today' ); + System.assertEquals( Date.newInstance( 2024, 02, 29 ), literal.getEndDate(), 'Today_getEndDate, will return today' ); + } + + @isTest + private static void Yesterday_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.Yesterday().toLiteral(); + System.assertEquals( 'YESTERDAY', got, 'Yesterday.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void Yesterday_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.Yesterday(); + + System.assertEquals( Date.newInstance( 2024, 02, 28 ), literal.getStartDate(), 'Yesterday_getStartDate, will return yesterday' ); + System.assertEquals( Date.newInstance( 2024, 02, 28 ), literal.getEndDate(), 'Yesterday_getEndDate, will return yesterday' ); + } } \ No newline at end of file From 432925a88eeffc30c680cf4462c1efb2e073b29d Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 13:37:22 +0000 Subject: [PATCH 12/17] Added tests for DateLiterals for weeks (and tomorrow) --- .../tests/ortoo_DateLiteralsTest.cls | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index 754f1215939..e62e54ecc45 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -332,4 +332,76 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( Date.newInstance( 2024, 02, 28 ), literal.getStartDate(), 'Yesterday_getStartDate, will return yesterday' ); System.assertEquals( Date.newInstance( 2024, 02, 28 ), literal.getEndDate(), 'Yesterday_getEndDate, will return yesterday' ); } + + @isTest + private static void Tomorrow_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.Tomorrow().toLiteral(); + System.assertEquals( 'TOMORROW', got, 'Tomorrow.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void Tomorrow_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.Tomorrow(); + + System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getStartDate(), 'Tomorrow_getStartDate, will return tomorrow' ); + System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getEndDate(), 'Tomorrow_getEndDate, will return tomorrow' ); + } + + @isTest + private static void LastWeek_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.LastWeek().toLiteral(); + System.assertEquals( 'LAST_WEEK', got, 'LastWeek.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void LastWeek_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastWeek(); + + System.assertEquals( ortoo_DateLiterals.startOfLastWeek, literal.getStartDate(), 'LastWeek_getStartDate, will return the start of last week' ); + System.assertEquals( ortoo_DateLiterals.endOfLastWeek, literal.getEndDate(), 'LastWeek_getEndDate, will return the end of last week' ); + } + + @isTest + private static void ThisWeek_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.ThisWeek().toLiteral(); + System.assertEquals( 'THIS_WEEK', got, 'ThisWeek.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void ThisWeek_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.ThisWeek(); + + System.assertEquals( ortoo_DateLiterals.startOfThisWeek, literal.getStartDate(), 'ThisWeek_getStartDate, will return the start of last week' ); + System.assertEquals( ortoo_DateLiterals.endOfThisWeek, literal.getEndDate(), 'ThisWeek_getEndDate, will return the end of last week' ); + } + + @isTest + private static void NextWeek_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.NextWeek().toLiteral(); + System.assertEquals( 'NEXT_WEEK', got, 'NextWeek.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void NextWeek_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.NextWeek(); + + System.assertEquals( ortoo_DateLiterals.startOfNextWeek, literal.getStartDate(), 'NextWeek_getStartDate, will return the start of last week' ); + System.assertEquals( ortoo_DateLiterals.endOfNextWeek, literal.getEndDate(), 'NextWeek_getEndDate, will return the end of last week' ); + } } \ No newline at end of file From e31bdd764b6d477ee806a0ade20bd1d9fe2fb2ed Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 13:50:53 +0000 Subject: [PATCH 13/17] Added tests for DateLiterals for months and next / last 90 days --- .../tests/ortoo_DateLiteralsTest.cls | 102 ++++++++++++++++-- 1 file changed, 96 insertions(+), 6 deletions(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index e62e54ecc45..5a193988330 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -305,7 +305,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void Today_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + private static void Today_getStartDateGetEndDate_returnsToday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -323,7 +323,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void Yesterday_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + private static void Yesterday_getStartDateGetEndDate_returnsYesterday() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -341,7 +341,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void Tomorrow_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + private static void Tomorrow_getStartDateGetEndDate_returnsTomorrow() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -359,7 +359,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void LastWeek_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + private static void LastWeek_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -377,7 +377,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void ThisWeek_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + private static void ThisWeek_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -395,7 +395,7 @@ private without sharing class ortoo_DateLiteralsTest } @isTest - private static void NextWeek_getStartDateGetEndDate_returnToday() // NOPMD: Test method name format + private static void NextWeek_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format { ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); @@ -404,4 +404,94 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( ortoo_DateLiterals.startOfNextWeek, literal.getStartDate(), 'NextWeek_getStartDate, will return the start of last week' ); System.assertEquals( ortoo_DateLiterals.endOfNextWeek, literal.getEndDate(), 'NextWeek_getEndDate, will return the end of last week' ); } + + @isTest + private static void LastMonth_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.LastMonth().toLiteral(); + System.assertEquals( 'LAST_MONTH', got, 'LastMonth.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void LastMonth_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastMonth(); + + System.assertEquals( Date.newInstance( 2024, 01, 01 ), literal.getStartDate(), 'LastMonth_getStartDate, will return the start of last month' ); + System.assertEquals( Date.newInstance( 2024, 01, 31 ), literal.getEndDate(), 'LastMonth_getEndDate, will return the end of last month' ); + } + + @isTest + private static void ThisMonth_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.ThisMonth().toLiteral(); + System.assertEquals( 'THIS_MONTH', got, 'ThisMonth.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void ThisMonth_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.ThisMonth(); + + System.assertEquals( Date.newInstance( 2024, 02, 01 ), literal.getStartDate(), 'ThisMonth_getStartDate, will return the start of last month' ); + System.assertEquals( Date.newInstance( 2024, 02, 29 ), literal.getEndDate(), 'ThisMonth_getEndDate, will return the end of last month' ); + } + + @isTest + private static void NextMonth_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.NextMonth().toLiteral(); + System.assertEquals( 'NEXT_MONTH', got, 'NextMonth.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void NextMonth_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.NextMonth(); + + System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getStartDate(), 'NextMonth_getStartDate, will return the start of last month' ); + System.assertEquals( Date.newInstance( 2024, 03, 31 ), literal.getEndDate(), 'NextMonth_getEndDate, will return the end of last month' ); + } + + @isTest + private static void Last90Days_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.Last90Days().toLiteral(); + System.assertEquals( 'LAST_90_DAYS', got, 'Last90Days.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void Last90Days_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.Last90Days(); + + System.assertEquals( Date.newInstance( 2023, 12, 01 ), literal.getStartDate(), 'Last90Days_getStartDate, will return 90 days ago' ); + System.assertEquals( Date.newInstance( 2024, 02, 29 ), literal.getEndDate(), 'Last90Days_getEndDate, will return the end of last month' ); + } + + @isTest + private static void Next90Days_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.Next90Days().toLiteral(); + System.assertEquals( 'NEXT_90_DAYS', got, 'Next90Days.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void Next90Days_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.Next90Days(); + + System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getStartDate(), 'Next90Days_getStartDate, will return tomorrow' ); + System.assertEquals( Date.newInstance( 2024, 05, 29 ), literal.getEndDate(), 'Next90Days_getEndDate, will return 90 days in the future' ); + } } \ No newline at end of file From 8ae7cb944a0b8bcd05f09549ac0c377b6b956a94 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 14:09:32 +0000 Subject: [PATCH 14/17] Added tests for last / next n Protect the data range comparers against invalid comparisons --- .../fflib-extension/ortoo_DateLiterals.cls | 6 +- .../tests/ortoo_DateLiteralsTest.cls | 110 +++++++++++++++++- 2 files changed, 113 insertions(+), 3 deletions(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index bdfc6fa01c9..7933f5cf064 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -514,12 +514,12 @@ public inherited sharing class ortoo_DateLiterals protected override Date getStartDate() { - return endOfLastMonth; + return startOfThisMonth.addMonths( numberOfThings * -1 ); } protected override Date getEndDate() { - return startOfThisMonth.addMonths( numberOfThings * -1 ); + return endOfLastMonth; } } @@ -599,6 +599,7 @@ public inherited sharing class ortoo_DateLiterals { public Integer compare( DateTime value, Date startDate, Date endDate ) { + Contract.requires( startDate <= endDate, 'compare called with a start date that is higher than the end date ('+ startDate + ', ' + endDate + ')' ); if ( value < DateTime.newInstance( startDate.year(), startDate.month(), startDate.day(), 0, 0, 0 ) ) { return -1; @@ -614,6 +615,7 @@ public inherited sharing class ortoo_DateLiterals private class DateToDateRangeComparer { public Integer compare( Date value, Date startDate, Date endDate ) { + Contract.requires( startDate <= endDate, 'compare called with a start date that is higher than the end date ('+ startDate + ', ' + endDate + ')' ); if ( value < startDate ) { return -1; diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index 5a193988330..eec22907b8b 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -474,7 +474,7 @@ private without sharing class ortoo_DateLiteralsTest ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.Last90Days(); System.assertEquals( Date.newInstance( 2023, 12, 01 ), literal.getStartDate(), 'Last90Days_getStartDate, will return 90 days ago' ); - System.assertEquals( Date.newInstance( 2024, 02, 29 ), literal.getEndDate(), 'Last90Days_getEndDate, will return the end of last month' ); + System.assertEquals( Date.newInstance( 2024, 02, 29 ), literal.getEndDate(), 'Last90Days_getEndDate, will return today' ); } @isTest @@ -494,4 +494,112 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getStartDate(), 'Next90Days_getStartDate, will return tomorrow' ); System.assertEquals( Date.newInstance( 2024, 05, 29 ), literal.getEndDate(), 'Next90Days_getEndDate, will return 90 days in the future' ); } + + @isTest + private static void LastNDays_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.LastNDays( 5 ).toLiteral(); + System.assertEquals( 'LAST_N_DAYS:5', got, 'LastNDays.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void LastNDays_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 5 ); + + System.assertEquals( Date.newInstance( 2024, 02, 24 ), literal.getStartDate(), 'LastNDays_getStartDate, will return n days ago' ); + System.assertEquals( Date.newInstance( 2024, 02, 29 ), literal.getEndDate(), 'LastNDays_getEndDate, will return today' ); + } + + @isTest + private static void NextNDays_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.NextNDays( 5 ).toLiteral(); + System.assertEquals( 'NEXT_N_DAYS:5', got, 'NextNDays.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void NextNDays_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.NextNDays( 5 ); + + System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getStartDate(), 'NextNDays_getStartDate, will return tomorrow' ); + System.assertEquals( Date.newInstance( 2024, 03, 05 ), literal.getEndDate(), 'NextNDays_getEndDate, will return n days in the future' ); + } + + @isTest + private static void LastNWeeks_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.LastNWeeks( 2 ).toLiteral(); + System.assertEquals( 'LAST_N_WEEKS:2', got, 'LastNWeeks.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void LastNWeeks_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNWeeks( 2 ); + + System.assertEquals( ortoo_DateLiterals.startOfLastWeek.addDays( -7 ), literal.getStartDate(), 'LastNWeeks_getStartDate, will return the start of last week minus the specified number of weeks' ); + System.assertEquals( ortoo_DateLiterals.endOfLastWeek, literal.getEndDate(), 'LastNWeeks_getEndDate, will return the end of last week' ); + } + + @isTest + private static void NextNWeeks_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.NextNWeeks( 2 ).toLiteral(); + System.assertEquals( 'NEXT_N_WEEKS:2', got, 'NextNWeeks.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void NextNWeeks_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.NextNWeeks( 2 ); + + System.assertEquals( ortoo_DateLiterals.startOfNextWeek, literal.getStartDate(), 'NextNWeeks_getStartDate, will return the first day of next week' ); + System.assertEquals( ortoo_DateLiterals.endOfNextWeek.addDays( 14 ), literal.getEndDate(), 'NextNWeeks_getEndDate, will the end of next week plus the specified number of weeks' ); + } + + @isTest + private static void LastNMonths_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.LastNMonths( 5 ).toLiteral(); + System.assertEquals( 'LAST_N_MONTHS:5', got, 'LastNMonths.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void LastNMonths_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNMonths( 5 ); + + System.assertEquals( Date.newInstance( 2023, 09, 01 ), literal.getStartDate(), 'LastNMonths_getStartDate, will return the first day of the month, n months ago' ); + System.assertEquals( Date.newInstance( 2024, 01, 31 ), literal.getEndDate(), 'LastNMonths_getEndDate, will return the end of last month' ); + } + + @isTest + private static void NextNMonths_toLiteral_returnsTheSoqlDateLiteral() // NOPMD: Test method name format + { + String got = new ortoo_DateLiterals.NextNMonths( 5 ).toLiteral(); + System.assertEquals( 'NEXT_N_MONTHS:5', got, 'NextNMonths.toLiteral, will return the SOQL Date Literal' ); + } + + @isTest + private static void NextNMonths_getStartDateGetEndDate_returnsRange() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.NextNMonths( 5 ); + + System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getStartDate(), 'NextNMonths_getStartDate, will return the start of next month' ); + System.assertEquals( Date.newInstance( 2024, 07, 31 ), literal.getEndDate(), 'NextNMonths_getEndDate, will return the end of the month, n months in the future' ); + } } \ No newline at end of file From 49d47c9a74ae1b9c9072f74368da2d1f8cc7f3a6 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 24 Feb 2022 14:54:56 +0000 Subject: [PATCH 15/17] Finished the date literal tests and fixed a boundary bug --- .../fflib-extension/ortoo_DateLiterals.cls | 8 +- .../tests/ortoo_DateLiteralsTest.cls | 104 ++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls index 7933f5cf064..79fde39d568 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls @@ -600,11 +600,13 @@ public inherited sharing class ortoo_DateLiterals public Integer compare( DateTime value, Date startDate, Date endDate ) { Contract.requires( startDate <= endDate, 'compare called with a start date that is higher than the end date ('+ startDate + ', ' + endDate + ')' ); + if ( value < DateTime.newInstance( startDate.year(), startDate.month(), startDate.day(), 0, 0, 0 ) ) { return -1; } - if ( value > DateTime.newInstance( endDate.year(), endDate.month(), endDate.day(), 23, 59, 29 ) ) + Date dayAfterTheEndDate = endDate.addDays( 1 ); + if ( value >= DateTime.newInstance( dayAfterTheEndDate.year(), dayAfterTheEndDate.month(), dayAfterTheEndDate.day(), 0, 0, 0 ) ) { return 1; } @@ -614,8 +616,10 @@ public inherited sharing class ortoo_DateLiterals private class DateToDateRangeComparer { - public Integer compare( Date value, Date startDate, Date endDate ) { + public Integer compare( Date value, Date startDate, Date endDate ) + { Contract.requires( startDate <= endDate, 'compare called with a start date that is higher than the end date ('+ startDate + ', ' + endDate + ')' ); + if ( value < startDate ) { return -1; diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls index eec22907b8b..8572ccac3bd 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls @@ -602,4 +602,108 @@ private without sharing class ortoo_DateLiteralsTest System.assertEquals( Date.newInstance( 2024, 03, 01 ), literal.getStartDate(), 'NextNMonths_getStartDate, will return the start of next month' ); System.assertEquals( Date.newInstance( 2024, 07, 31 ), literal.getEndDate(), 'NextNMonths_getEndDate, will return the end of the month, n months in the future' ); } + + @isTest + private static void compare_whenGivenADateBeforeTheRange_returnsMinus1() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( Date.newInstance( 2024, 02, 21 ) ); + Test.stopTest(); + + System.assertEquals( -1, got, 'compare, when given a date before the range, will return minus 1' ); + } + + @isTest + private static void compare_whenGivenADateInsideTheRange_returnsZero() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( Date.newInstance( 2024, 02, 23 ) ); + Test.stopTest(); + + System.assertEquals( 0, got, 'compare, when given a date inside the range, will return zero' ); + } + + @isTest + private static void compare_whenGivenADateAfterTheRange_returns1() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( Date.newInstance( 2024, 02, 24 ) ); + Test.stopTest(); + + System.assertEquals( 1, got, 'compare, when given a date after the range, will return one' ); + } + + @isTest + private static void compare_whenGivenADateTimeJustBeforeTheRange_returnsMinus1() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( DateTime.newInstance( 2024, 02, 21, 23, 59, 59 ) ); + Test.stopTest(); + + System.assertEquals( -1, got, 'compare, when given a datetime just before the range, will return minus 1' ); + } + + @isTest + private static void compare_whenGivenADateTimeJustAtStartOfTheRange_returnsZero() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( DateTime.newInstance( 2024, 02, 22, 0, 0, 1 ) ); + Test.stopTest(); + + System.assertEquals( 0, got, 'compare, when given a datetime just at the start of the range, will return 0' ); + } + + @isTest + private static void compare_whenGivenADateTimeInTheMiddleOfTheRange_returnsZero() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( DateTime.newInstance( 2024, 02, 22, 12, 0, 0 ) ); + Test.stopTest(); + + System.assertEquals( 0, got, 'compare, when given a datetime in the middle of the range, will return 0' ); + } + + @isTest + private static void compare_whenGivenADateTimeJustAtEndOfTheRange_returnsZero() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( DateTime.newInstance( 2024, 02, 23, 23, 59, 59 ) ); + Test.stopTest(); + + System.assertEquals( 0, got, 'compare, when given a datetime just at the end of the range, will return 0' ); + } + + @isTest + private static void compare_whenGivenADateTimeJustAfterTheRange_returns1() // NOPMD: Test method name format + { + ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 23 ); + ortoo_DateLiterals.DateRangeLiteral literal = new ortoo_DateLiterals.LastNDays( 1 ); + + Test.startTest(); + Integer got = literal.compare( DateTime.newInstance( 2024, 02, 24, 0, 0, 0 ) ); + Test.stopTest(); + + System.assertEquals( 1, got, 'compare, when given a datetime just after the range, will return 1' ); + } } \ No newline at end of file From 38da713d2131b046b95e71373b1b91deef836566 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Mon, 28 Feb 2022 11:30:19 +0000 Subject: [PATCH 16/17] Added test and documentation to fflib objects relating to DateLiteral changes --- .../classes/criteria/fflib_Comparator.cls | 2 -- .../classes/criteria/fflib_Criteria.cls | 8 +++++-- .../classes/tests/fflib_ComparatorTest.cls | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls index 2f462c78d47..f37c7cd55da 100644 --- a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls +++ b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Comparator.cls @@ -30,7 +30,6 @@ */ public with sharing class fflib_Comparator { - public interface Comparable { Integer compare( Object otherValue ); @@ -58,7 +57,6 @@ public with sharing class fflib_Comparator public static Integer compare(Object object1, Object object2) { - // TODO: test if ( object2 instanceOf Comparable ) { return ((Comparable)object2).compare( object1 ); } diff --git a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls index 63db20059e1..6493afe008a 100755 --- a/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls +++ b/framework/default/fflib-apex-extensions/default/classes/criteria/fflib_Criteria.cls @@ -768,7 +768,12 @@ public virtual with sharing class fflib_Criteria this.embraced = embraced; } - // TODO: move - consider adding to the original library + /** + * Defines a 'Literal' that can be used as to compare against. + * For example, a Date Literal such as TODAY. + * + * @param embraced Braces will be added if set to TRUE + */ public interface Literal { String toLiteral(); } @@ -782,7 +787,6 @@ public virtual with sharing class fflib_Criteria { if (value == null) return 'null'; - // TODO: test this if ( value instanceOf Literal ) { return ((Literal)value).toLiteral(); diff --git a/framework/default/fflib-apex-extensions/default/classes/tests/fflib_ComparatorTest.cls b/framework/default/fflib-apex-extensions/default/classes/tests/fflib_ComparatorTest.cls index 7b86fd36c93..7c57a39b33b 100644 --- a/framework/default/fflib-apex-extensions/default/classes/tests/fflib_ComparatorTest.cls +++ b/framework/default/fflib-apex-extensions/default/classes/tests/fflib_ComparatorTest.cls @@ -270,4 +270,27 @@ private with sharing class fflib_ComparatorTest System.assert(exceptionThrown); } + + @isTest + private static void compare_whenGivenAComparatorComparable_callsCompareAgainstThat() // NOPMD: Test method name format + { + Test.startTest(); + Integer got = fflib_Comparator.compare( 'object1', new ComparableThing() ); + Test.stopTest(); + + System.assertEquals( 0, got, 'compare, when given an instance of Comparator.Comparable in object2, will call compare against that and return the result' ); + } + + class ComparableThingCalledWithUnexpectedValueException extends Exception {} + class ComparableThing implements fflib_Comparator.Comparable + { + public Integer compare( Object otherValue ) + { + if ( otherValue == 'object1' ) + { + return 0; + } + throw new ComparableThingCalledWithUnexpectedValueException(); + } + } } \ No newline at end of file From fb6a7be3abee2657ba291faedfef7650d6c1b9b7 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Mon, 28 Feb 2022 11:35:08 +0000 Subject: [PATCH 17/17] Removed codecoverage from the apex test runs (buggy) --- .github/workflows/create-org-and-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-org-and-deploy.yaml b/.github/workflows/create-org-and-deploy.yaml index cc576581928..36353591e48 100644 --- a/.github/workflows/create-org-and-deploy.yaml +++ b/.github/workflows/create-org-and-deploy.yaml @@ -68,7 +68,7 @@ jobs: # Run Apex Unit Tests - name: Run Apex Unit Tests - run: sfdx force:apex:test:run -r human -u "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" --codecoverage --wait 20 | grep -v ' Pass '; test ${PIPESTATUS[0]} -eq 0 + run: sfdx force:apex:test:run -r human -u "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" --wait 20 | grep -v ' Pass '; test ${PIPESTATUS[0]} -eq 0 # Prepare Jest Modules