You need to sign in to do that
Don't have an account?
MUSFAR KT 6
test class help is needed
public class Promise implements Finalizer, Queueable {
private Function resolve;
private Function reject;
private Promise next;
private Function last;
private Function onError;
private Object result;
private Object arg;
public Promise(Function resolve, Function reject) {
this.resolve = resolve;
this.reject = reject;
}
public void execute(System.QueueableContext ctx) {
System.attachFinalizer(this);
result = this.resolve.apply(this.arg);
}
public void execute(System.FinalizerContext ctx) {
}
public Promise then(Promise promise) {
if(this.next != null) {
this.next = next;
} else {
this.next.then(promise);
}
return this;
}
public void setArg(Object arg) {
this.arg = arg;
}
public Promise onCatch(Function onError) {
this.onError = onError;
return this;
}
}
private Function resolve;
private Function reject;
private Promise next;
private Function last;
private Function onError;
private Object result;
private Object arg;
public Promise(Function resolve, Function reject) {
this.resolve = resolve;
this.reject = reject;
}
public void execute(System.QueueableContext ctx) {
System.attachFinalizer(this);
result = this.resolve.apply(this.arg);
}
public void execute(System.FinalizerContext ctx) {
}
public Promise then(Promise promise) {
if(this.next != null) {
this.next = next;
} else {
this.next.then(promise);
}
return this;
}
public void setArg(Object arg) {
this.arg = arg;
}
public Promise onCatch(Function onError) {
this.onError = onError;
return this;
}
}
I am trying to save this apex class but I am seeing the errors -"Invalid type: Function" and "Variable does not exist: resolve".
On a general note, the below articles give a good insight into how to begin writing test class and how coverage can be improved
https://salesforce.stackexchange.com/questions/244788/how-do-i-write-an-apex-unit-test
https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines
Examples:
https://salesforce.stackexchange.com/questions/149541/how-to-write-test-class-for-chained-enqueued-jobs/149548
https://salesforce.stackexchange.com/questions/310307/in-an-unit-test-for-an-lwc-how-can-i-prove-an-async-chain-is-setting-a-value-in
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you