Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Created TestSObjectBuilder.cls #83

Closed
wants to merge 34 commits into from
Closed

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Sep 19, 2017

For the foreseeable future, Nebula will remain an unmanaged package (Salesforce's requirements for managed packages make it difficult to make certain changes, like deprecating classes and methods). Ideally, it should be possible to easily upgrade Nebula between minor versions (example: v2.0 to v2.1). However, in order to provide test coverage, Nebula needs to occasionally create & insert records in unit tests. When deployed to an org with custom required fields, Nebula's tests will fail because the tests do not know about the custom fields.

To make upgrades easier - and to provide a reusable test data generator - the class TestSObjectBuilder has been created. I also plan to limit test data generation to 3 standard objects. If no required fields have been added to these objects, then no additional action will be needed to get Nebula to work. But if custom required fields have been added, then an additional class needs to be created to tell Nebula what fields & values to use for creating test records

  • Account - class 'TestAccountBuilder' that extends TestSObjectBuilder.Base must be created
  • Contact - class 'TestContactBuilder' that extends TestSObjectBuilder.Base must be created
  • Lead - class 'TestLeadBuilder' that extends TestSObjectBuilder.Base must be created

Since these classes will be created directly in the org and are not part of the Nebula repo, they will not be overwritten during upgrades. This will allow Nebula to be upgradeable without having to directly modify the framework.

Fixes #43

jamessimone and others added 30 commits May 11, 2017 09:11
* bringing Nebula up to date with the implemented SObjectRepository and surrounding classes we've been using

* making QueryOperator static

* build fixes

* exceptions consolidated

* removing unnecessary overrides in SObjectRepository_Tests and unused exception (has been consolidated into Exceptions.cls)

* adding test coverage and fixed a few issues

* code review changes

* fixing awkward .isEmpty() checks

* fixing a slight bug that came up while testing predicates with schedulable interfaces today - a null reference exception could be thrown in certain instances

* adding test coverage

* removing commented out test
…ueries

* Children queries can now be included in your query results
* QueryFilter.cls is now used to handle filtering on the base object, parent object fields and grandparent fields - the constructor used determines the type of filter
* QueryBuilder.whereField() method has been replaced by QueryBuilder.filterBy() - it expects either a single instance or a list of QueryFilter.cls
* SObjectRepository.cls has a new constructor that will automatically add all fields to the query for the specified SObject type - essentially, it's 'select * from sobject' 
* SObjectRepository.queryFactory is now SObjectRepository.Query
* Created SObjectFieldDescriber.cls & SObjectTypeDescriber.cls
* Miscellaneous cleanup - variable name standardisation, whitespace, etc
* Removed the method ISObjectRepository.getCreatedSinceTimeValue
* Deleted CollectionUtils.cls

It was only used in 2 mock classes and only had a very basic method in it

* Added missing license info to the top of a few classes

* Deleted an unused exception class

* Cleaned up some variables, whitespace, etc

* More tweaks to whitespace

* Capitalised a data type

* Added some whitespace to // inline comments

* Changed a variable to a more meaningful name

* Removed an unused private method

* Cleaned up the order of steps in QueryBuilder's constructors

Now it matches the order of the private variables being set
* Added a Nebula app - it currently has a tab for logs, more tabs will be added in the future
* Logging is now enabled by default (via custom setting)
* Updated all classes to API v39.0
* Updated naming convention for IDML.cls methods & eliminated the return types
* Added support to SObjectRepository.cls for upserting by an external ID
* Cleaned up methods names in SObjectRepository.cls
* Overloaded getSearchResults in SObjectRepository.cls to allow more control for SOSL results
* Added a missing test class, Logger_Tests.cls
* Added interface IQueryArgumentFormatter.cls
* RecordTypes.cls now uses Schema.SObjectType insteadof Schema.DescribeSObjectResult in its constructor
* RecordTypes.cls now internally uses QueryBuilder.cls
* QueryBuilder.cls now always sorts the list of query fields * the custom setting for this has been removed
* Fixed some issues with TestingUtils.setReadOnlyField()
* Deleted CollectionUtils.cls
* Added missing license info to the top of a few classes
* Miscellaneous bugfixes, additional unit tests, variable name updates, etc.
…rror

Specified Node JS version in .travis.yml to fix a Travis deployment error
* Added .codeclimate.yml & rules (in ./tools/codeclimate)
* Refactored some classes based on CC's feedback
* Rewrote README.md
* Fixed a few miscellaneous bugs
* Added .gitattributes to help handle line endings in the repo
* Created CollectionUtils.cls to determine the collection type of an obj

* QueryArgumentFormatter now handles lists, maps & sets. Previously, only lists were handled

* Fixed some w  h  i  t  e  s  p  a  c  e

* Added comments to CollectionUtils to explain the hacks

* Added 3 tests for each collection type + some negative tests
…#64)

* Fixes issue #42 - scheduler class with simple CRON scheduling methods

* added scheduler tests, code review feedback, fixed a test that could break with multiple user environments
This allows the main class, TestSObjectBuilder, to be marked as @istest, and the inner class, Base, can be marked as an abstract class
- 3 new query builder classes: SObjectQueryBuilder (standard SOQL queries, AggregateResultQueryBuilder (aggregate SOQL queries) and SearchQueryBuilder (SOSL queries)
    * QueryBuilder.cls is now an abstract class, used by the 3 types of query builders for shared logic
    * Added QueryField.cls - parses an SObjectField or list of SObjectFields into the SOQL/SOSL string version. This can be used as a field in your 'SELECT' statement, as a field for QueryFilter, and in the 'ORDER BY' statement
    * Added QueryDate.cls - this represents date functions for date & datetime fields, like 'CALENDAR_MONTH(CreatedDate)'. QueryDates can be used in QueryFilter, as an aggregate result field, and in the 'ORDER BY' statement
- DML methods now return a list of corresponding database result types
- Began adding ApexDoc to classes
The sharing model is purposefully not set in Nebula on most classes so that the implementation can control it
The idea here is that if a class has been deployed with one of the string names, then that Type is used. Otherwise, the subclasses are used as fallback.
…nto test-sobject-builder

# Conflicts:
#	.codeclimate.yml
@jongpie
Copy link
Owner Author

jongpie commented Jun 5, 2018

Closing this PR - I'm going to use a different approach instead.

@jongpie jongpie closed this Jun 5, 2018
@ghost ghost removed the in progress label Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants