-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,51 @@ | ||
<span class="hljs-comment">/** | ||
* <span class="hljs-doctag">@author </span>John Smith | ||
*/</span> | ||
<span class="hljs-annotation"><span class="hljs-meta annotations">@IsTest</span><span class="hljs-punctuation">(</span><span class="hljs-meta keyword">Seealldata</span><span class="hljs-operator">=</span><span class="hljs-literal">true</span><span class="hljs-punctuation end">)</span></span> | ||
<span class="hljs-keyword">public</span> <span class="hljs-keyword">with sharing</span> <span class="hljs-class-declaration"><span class="hljs-keyword">class</span> <span class="hljs-title class_">L2Char</span> <span class="hljs-keyword">implements</span> <span class="hljs-built_in">Database</span>.<span class="hljs-title class_ inherited__">batchable</span> <span class="hljs-punctuation">{</span></span> | ||
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable">ERROR</span> <span class="hljs-operator">=</span> <span class="hljs-number">0x0001</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-annotation"><span class="hljs-meta">@IsTest</span><span class="hljs-punctuation">(</span><span class="hljs-meta keyword">Seealldata</span><span class="hljs-operator">=</span><span class="hljs-literal">true</span><span class="hljs-punctuation">)</span></span> | ||
<span class="hljs-keyword">public</span> <span class="hljs-keyword">with sharing</span> <span class="hljs-class_declaration">class <span class="hljs-title class_">L2Char</span> <span class="hljs-implements block"><span class="hljs-keyword">implements</span> <span class="hljs-built_in">Database</span>.<span class="hljs-title class_ inherited__">batchable</span> </span><span class="hljs-punctuation">{</span></span><span class="hljs-punctuation">{</span> | ||
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable assigned">ERROR</span> <span class="hljs-operator">=</span> <span class="hljs-number">0x0001</span><span class="hljs-punctuation">;</span> | ||
|
||
<span class="hljs-annotation"><span class="hljs-meta annotations">@InvocableApex</span><span class="hljs-punctuation">(</span><span class="hljs-meta keyword">label</span><span class="hljs-operator">=</span><span class="hljs-string">'my invocable'</span><span class="hljs-punctuation end">)</span></span> | ||
<span class="hljs-keyword">public</span> <span class="hljs-type">void</span> moveTo<span class="hljs-punctuation">(</span> | ||
<span class="hljs-type">integer</span> x<span class="hljs-punctuation">,</span> | ||
<span class="hljs-type">integer</span> y<span class="hljs-punctuation">,</span> | ||
<span class="hljs-type">integer</span> z | ||
<span class="hljs-punctuation">)</span> <span class="hljs-punctuation">{</span> | ||
<span class="hljs-annotation"><span class="hljs-meta">@InvocableMethod</span><span class="hljs-punctuation">(</span><span class="hljs-meta keyword">label</span><span class="hljs-operator">=</span><span class="hljs-meta string">'my invocable'</span><span class="hljs-punctuation">)</span></span> | ||
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-type">void</span> <span class="hljs-method_call"><span class="hljs-title function_ invoke__">moveTo</span><span class="hljs-params"><span class="hljs-punctuation">(</span> | ||
<span class="hljs-type">Integer</span> <span class="hljs-variable">x</span>, | ||
<span class="hljs-type">Integer</span> <span class="hljs-variable">y</span>, | ||
<span class="hljs-type">Integer</span> <span class="hljs-variable">z</span> | ||
<span class="hljs-punctuation">)</span></span></span> <span class="hljs-punctuation">{</span> | ||
|
||
|
||
<span class="hljs-type">Account</span> <span class="hljs-variable">a</span> <span class="hljs-operator">=</span> <span class="hljs-instantiate"><span class="hljs-keyword">new</span> <span class="hljs-title function_ invoke__">Account</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
a.<span class="hljs-type">Custom__c</span> <span class="hljs-operator">=</span> <span class="hljs-string">'stringvalue'</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-built_in">insert</span> <span class="hljs-variable">a</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-type">Boolean</span> <span class="hljs-variable">ai</span> <span class="hljs-operator">=</span> <span class="hljs-punctuation">(</span><span class="hljs-type">Boolean</span><span class="hljs-punctuation">)</span> <span class="hljs-variable">false</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-built_in">System</span>.<span class="hljs-title function_ invoked__">debug</span><span class="hljs-punctuation">(</span><span class="hljs-string">'Should not be called'</span><span class="hljs-punctuation">)</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-keyword">if</span> <span class="hljs-punctuation">(</span><span class="hljs-number">1</span><span class="hljs-operator"> > </span><span class="hljs-number">5</span><span class="hljs-punctuation">)</span> <span class="hljs-punctuation">{</span> <span class="hljs-comment">// wtf!? | ||
</span> <span class="hljs-built_in">Database</span>.<span class="hljs-title function_ invoked__">insert</span><span class="hljs-punctuation">(</span>myAccounts<span class="hljs-punctuation">)</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-type">Account</span> <span class="hljs-variable assigned">a</span> <span class="hljs-operator">=</span> <span class="hljs-instantiate"><span class="hljs-keyword">new</span> <span class="hljs-title function_ invoke__">Account</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
a.Custom__c <span class="hljs-operator">=</span> <span class="hljs-string">'stringvalue'</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-dml"><span class="hljs-built_in"> insert </span><span class="hljs-variable">a</span>;</span> | ||
<span class="hljs-type">Boolean</span> <span class="hljs-variable assigned">ai</span> <span class="hljs-operator">=</span> <span class="hljs-punctuation">(</span><span class="hljs-type">Boolean</span><span class="hljs-punctuation">)</span> <span class="hljs-literal">false</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-method_call"><span class="hljs-built_in">System</span>.<span class="hljs-title function_ invoke__">debug</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-string">'Should not be called'</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-method_call"><span class="hljs-title function_ invoke__">if</span> <span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-number">1</span><span class="hljs-operator"> > </span><span class="hljs-number">5</span> <span class="hljs-operator">&&</span> <span class="hljs-operator">!</span><span class="hljs-built_in">Test</span>.isRunningTest(<span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">)</span> <span class="hljs-punctuation">{</span> <span class="hljs-comment">// wtf!? | ||
</span> <span class="hljs-database_dml"><span class="hljs-built_in">Database</span>.<span class="hljs-built_in">insert</span>(myAccounts, <span class="hljs-literal regex">false</span>);</span> | ||
<span class="hljs-punctuation">}</span> | ||
<span class="hljs-punctuation">}</span> | ||
<span class="hljs-punctuation">}</span> | ||
|
||
<span class="hljs-meta SOLO">@TestSetup</span> | ||
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-type">void</span> makeData<span class="hljs-punctuation">(</span><span class="hljs-type">Boolean</span> a<span class="hljs-punctuation">)</span><span class="hljs-punctuation">{</span> | ||
<span class="hljs-type">Custom__c</span> <span class="hljs-variable">c</span> <span class="hljs-operator">=</span> <span class="hljs-instantiate"><span class="hljs-keyword">new</span> <span class="hljs-title function_ invoke__">Custom__c</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-meta">@TestSetup</span> | ||
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-type">void</span> <span class="hljs-method_call"><span class="hljs-title function_ invoke__">makeData</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-type">Boolean</span> <span class="hljs-variable">a</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">{</span> | ||
<span class="hljs-type">Custom__c</span> <span class="hljs-variable assigned">c</span> <span class="hljs-operator">=</span> <span class="hljs-instantiate"><span class="hljs-keyword">new</span> <span class="hljs-title function_ invoke__">Custom__c</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
|
||
<span class="hljs-keyword">for</span><span class="hljs-punctuation">(</span><span class="hljs-type">Account</span> <span class="hljs-variable">a</span><span class="hljs-punctuation"> :</span> acctLis ){ | ||
ConnectApi.<span class="hljs-built_in">insert</span> <span class="hljs-variable">a</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-for_loop"><span class="hljs-keyword">for</span><span class="hljs-punctuation">(</span><span class="hljs-type">Account</span> <span class="hljs-variable for">a</span><span class="hljs-operator"> :</span> <span class="hljs-variable">acctLis</span> <span class="hljs-punctuation">){</span></span> | ||
ConnectApi.<span class="hljs-built_in">insert</span> a<span class="hljs-punctuation">;</span> | ||
<span class="hljs-punctuation">}</span> | ||
<span class="hljs-punctuation">}</span> | ||
|
||
<span class="hljs-keyword">private</span> <span class="hljs-keyword">testMethod</span> <span class="hljs-type">void</span> testme<span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span><span class="hljs-punctuation">{</span> | ||
<span class="hljs-built_in">System</span>.<span class="hljs-title function_ invoked__">assert</span><span class="hljs-punctuation">(</span><span class="hljs-literal">true</span><span class="hljs-punctuation">)</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-meta">@isTest</span> | ||
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-type">void</span> <span class="hljs-method_call"><span class="hljs-title function_ invoke__">testme</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">{</span> | ||
<span class="hljs-method_call"><span class="hljs-built_in">System</span>.<span class="hljs-title function_ invoke__">assert</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-literal regex">true</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-punctuation">}</span> | ||
|
||
<span class="hljs-meta SOLO">@testVisible</span> | ||
<span class="hljs-keyword">private</span> <span class="hljs-collection"><span class="hljs-type">List</span><span class="hljs-punctuation"><</span><span class="hljs-type">SelectOption</span><span class="hljs-punctuation">></span></span> recordTypes <span class="hljs-punctuation">{</span> <span class="hljs-variable">get</span><span class="hljs-punctuation">;</span> <span class="hljs-keyword">private</span> <span class="hljs-variable">set</span><span class="hljs-punctuation">;</span> <span class="hljs-punctuation">}</span> | ||
<span class="hljs-meta">@testVisible</span> | ||
<span class="hljs-keyword">private</span> <span class="hljs-collection"><span class="hljs-type">List</span><span class="hljs-punctuation"><</span><span class="hljs-type">SelectOption</span><span class="hljs-punctuation">></span></span> <span class="hljs-property">recordTypes</span> { <span class="hljs-keyword">get</span><span class="hljs-punctuation">;</span> <span class="hljs-keyword">private</span> <span class="hljs-keyword">set</span><span class="hljs-punctuation">;</span> <span class="hljs-punctuation">}</span> | ||
|
||
<span class="hljs-keyword">for</span><span class="hljs-punctuation">(</span><span class="hljs-type">Account</span> <span class="hljs-variable">a</span><span class="hljs-punctuation"> :</span> <span class="hljs-soql"><span class="hljs-punctuation">[</span><span class="hljs-keyword for soql">SELECT</span> Id <span class="hljs-from clause"><span class="hljs-keyword">FROM</span><span class="hljs-type"> Account</span></span> <span class="hljs-keyword">WHERE</span> LastModifiedDate <span class="hljs-operator">=</span> <span class="hljs-variable language_">LAST_N_DAYS</span><span class="hljs-operator">:</span><span class="hljs-number">3</span><span class="hljs-punctuation">]</span></span>){ | ||
<span class="hljs-title class_">Assert</span>.<span class="hljs-title function_ invoke__">fail</span><span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-for_loop"><span class="hljs-keyword">for</span><span class="hljs-punctuation">(</span><span class="hljs-type">Account</span> <span class="hljs-variable for">a</span><span class="hljs-operator"> :</span> <span class="hljs-soql"><span class="hljs-punctuation">[</span><span class="hljs-keyword soql">SELECT</span> Id <span class="hljs-from_clause"><span class="hljs-keyword">FROM</span><span class="hljs-type"> Account</span></span> <span class="hljs-keyword soql">WHERE</span> LastModifiedDate <span class="hljs-operator">=</span> <span class="hljs-variable language_">LAST_N_DAYS</span><span class="hljs-operator">:</span><span class="hljs-number">3</span><span class="hljs-punctuation">]</span></span><span class="hljs-punctuation">){</span></span> | ||
<span class="hljs-method_call"><span class="hljs-class title_">Assert</span>.<span class="hljs-title function_ invoke__">fail</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-punctuation">}</span> | ||
|
||
<span class="hljs-trigger_declaration"><span class="hljs-keyword">trigger</span> <span class="hljs-title class_">CTrig</span> <span class="hljs-operator">on</span> <span class="hljs-type">Custom__c</span> <span class="hljs-trigger_params"><span class="hljs-punctuation">(</span><span class="hljs-built_in">before insert</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">{</span> | ||
<span class="hljs-built_in">System</span>.<span class="hljs-title function_ invoked__">debug</span><span class="hljs-punctuation">(</span><span class="hljs-string">'inserting a record'</span><span class="hljs-punctuation">)</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-built_in">upsert</span> <span class="hljs-variable">myRecord__c</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-method_call"><span class="hljs-built_in">System</span>.<span class="hljs-title function_ invoke__">debug</span><span class="hljs-params"><span class="hljs-punctuation">(</span><span class="hljs-string">'inserting a record'</span><span class="hljs-punctuation">)</span></span></span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-dml"><span class="hljs-built_in"> upsert </span><span class="hljs-variable">myRecord__c</span>;</span> | ||
<span class="hljs-punctuation">}</span> |