• Tony Rush 3
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I am looking at this page:

https://developer.salesforce.com/tools/vscode/en/apex/testing/

It mentions "Run All Tests" and "Run Test". The problem is that I don't see these links within my Test class. I did click the 'Beaker' icon and try to run tests that way, but I get an error that "Java runtime could not be located" and pointing me to this site:

https://developer.salesforce.com/tools/vscode/en/getting-started/java-setup

Ok, well I do have Java installed at 'C:\Program Files (x86)\Java\jre1.8.0_231' so I tried to set that as the Java home setting. But still unfortunately testing via the side panel doesn't work, and I still don't see those "Run Test" links.

Can someone provide some guidance please? Does this problem have to do with that Java setting and if so what should I be setting that to exactly?
I am looking at this page:

https://developer.salesforce.com/tools/vscode/en/apex/testing/

It mentions "Run All Tests" and "Run Test". The problem is that I don't see these links within my Test class. I did click the 'Beaker' icon and try to run tests that way, but I get an error that "Java runtime could not be located" and pointing me to this site:

https://developer.salesforce.com/tools/vscode/en/getting-started/java-setup

Ok, well I do have Java installed at 'C:\Program Files (x86)\Java\jre1.8.0_231' so I tried to set that as the Java home setting. But still unfortunately testing via the side panel doesn't work, and I still don't see those "Run Test" links.

Can someone provide some guidance please? Does this problem have to do with that Java setting and if so what should I be setting that to exactly?
Hi there.

In my lightning app I have a few components:
  • one component has a ui:inputSelect and registers an event. the ui:inputSelect has a change attribute that fires a function, wherein the selected text (an ID) is put in an event and fired.
  • one component that handles the event, is an aura:iteration list of a component that, on handling the event, should retrieve a list of items where a master-child lookup is the sent ID of the master object. This then displays all those child objects.
  • the other component that handles the event, has three inputText fields, that are supposed to display the other fields of the master object
The problem: either the event seems to not be fired, or the handlers seem to not be activated.

I put console.debug's, alerts and component.set("v.testmessage", "fired") 's in the handlers but they never execute.
I then put one of the handlers as the init-handler and then it did execute the handler (with an undefined ID since the event hadn't yet been fired, which is reasonable).

I have triple-checked the event name, event type and handler action, everything matches. I have no compilation problems, I have no errors when I am using my app. 
I also have no response whatsoever from my event. Any ideas?

**Registering component**
<aura:component controller="PrefixMasterHeaderSelectorController">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:registerEvent name="updateMaster" type="c:PrefixMasterEvent" />
    <aura:attribute name="masters" type="PrefixMaster__c[]"/>
      
    <label class="slds-master-element__label" for="masterSelector">Select a master to work with:</label>
    <div class="slds-master-element__control">
        <div class="slds-select_container">
            
            <ui:inputSelect aura:id="masterID" class="slds-select" change="{!c.masterHasChanged}">
                <aura:iteration items="{!v.masters}" var="master">
                    <ui:inputSelectOption text="{!master.Id}" label="{!master.Name}" />
                    <!-- + ' (Last modified: ' + master.LastModifiedDate + ' by ' + master.LastModifiedBy.Name + ')'}"/> -->
                </aura:iteration>	
                <ui:inputSelectOption text="newMaster" label="Create a new master" />
            </ui:inputSelect>
            
        </div>
    </div>

    <c:PrefixMasterHeaderMaster />
</aura:component>

**Registering controller**
({
    doInit : function(component, event, helper) {
        // Create the action
        var action = component.get("c.getMasters");
    
        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.masters", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
    
        // Send action off to be executed
        $A.enqueueAction(action);
    },
    
    masterHasChanged : function(component, event, helper) {
        var masterID = component.find("masterID").get("v.value");
        var masterEvent = component.getEvent("updateMaster");
        masterEvent.setParams({"master" : masterID})
        masterEvent.fire();
        
		console.debug('UPDATE MASTER = ' + masterID);
        alert('Hiya! masterEvent ' + masterEvent.getParam("master"));
    }
		
})

**List-child component**
<aura:component controller="PrefixListChildsController">
	<aura:handler name="updateForm" event="c:PrefixFormEvent" action="{!c.loadChilds}" />
    <aura:attribute name="childs" type="PrefixChild__c[]"/>
    
	<!--   	<aura:handler name="saveChild" event="c:PrefixChildEvent" action="{!c.handleAddItem}"/> -->
    <!--	to reload the masters after adding a new child -->
    
    <div>
        <header class="slds-p-top--small">
            <h3 class="slds-text-heading--small">Childs</h3>
        </header>
        
        <div id="list" class="row">
            <aura:iteration items="{!v.childs}" var="child">
                <aura:if isTrue="{!child.Order__c % 2 == 1}">
                        <div class="slds-p-around--small" style="background-color: lightblue; border-radius: 10px">
                            <c:PrefixChild child="{!child}"/>
                        </div>
                    <aura:set attribute="else" >
                        <div class="slds-p-around--small" style="background-color: none; border-radius: 10px">
                            <c:PrefixChild child="{!child}"/>
                        </div>
                    </aura:set>
                </aura:if>
            </aura:iteration>
            {!v.testEventmessage}
            <c:PrefixNewChild />
        </div>
    </div>

</aura:component>

**List-child controller.js**
({
	loadChilds : function(component, event, helper) {
 	    var action = component.get("c.getChilds");
		var masterID = event.getParam("master");    
    	action.setParams({ "masterID" : masterID });
        
        console.debug('master id = ' + masterID);
        alert('load childs ' + masterID);
        component.set("v.testEventmessage", masterID);

        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.childs", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        
        // Send action off to be executed
        $A.enqueueAction(action);
    }
})


 
I am using Lightning frame to render d3 type of spider view UI, on click of nodes in the spider view, I am supposed to make as APEX call to fetch the JSON data to render the node. I have earlier called server side code using $A.enqueueAction(action), but when I perform the same within my filestore java script action.setCallback does not get called, it looks as if it has hit a dead lock. I have noticed one more behavior if I force the code to throw an exception the call-back gets called. It looks like Lightning framework has some limitation while making an asynchronous calls with in non-blocking function calls. I am attaching the code with 3 scenariosfor your perusal, if you could help me understand the behaviors of the code that will be of great help.
Scenario A : lightningAction.setCallback does not get called.

var paramss= JSON.stringify(params);
	var deferred = $.Deferred();
	var lightningAction = lightningComponent.get("c.invokeAppToolKitGet");			

	lightningAction.setParams({
		"parameters": paramss
	});

lightningAction.setCallback(this, function(response){
		var state = response.getState();														
		if (state === "SUCCESS") {  
			var calloutRes = response.getReturnValue();
			var callBackResponse = JSON.parse(calloutRes);
callBackResponse.data.data.entity = 
                   JSON.stringify(callBackResponse.data.data.entity);
			deferred.resolve(callBackResponse);
		}
		else{	
			deferred.reject('Error');								
		}  							
	});	
						
	$A.enqueueAction(lightningAction);		
						
	var promise = deferred.then(function(response) { 
		//Parse the response and build the node object
	}

	return promise;
Scenario B : Introduced $A.getCallback that throws an exception, with this change the call back get called, but the main code breaks since remaining code was not processed due to exeption.

var paramss= JSON.stringify(params);
	var deferred = $.Deferred();
	var lightningAction = lightningComponent.get("c.invokeAppToolKitGet");			

	lightningAction.setParams({
		"parameters": paramss
	});

lightningAction.setCallback(this, function(response){
		var state = response.getState();														
		if (state === "SUCCESS") {  
			var calloutRes = response.getReturnValue();
			var callBackResponse = JSON.parse(calloutRes);
callBackResponse.data.data.entity = 
                   JSON.stringify(callBackResponse.data.data.entity);
			deferred.resolve(callBackResponse);
		}
		else{	
			deferred.reject('Error');								
		}  							
	});	
						
	$A.enqueueAction(lightningAction);		
	
	$A.getCallback(function() {						
	});
					
	var promise = deferred.then(function(response) { 
		//Parse the response and build the node object
	}

	return promise;
Scenario C : The call back does not get called. Since we catch the exception and main code gets processed and call back in not getting called. It looks like Thread locking scenario in Java.

var paramss= JSON.stringify(params);
	var deferred = $.Deferred();
	var lightningAction = lightningComponent.get("c.invokeAppToolKitGet");			

	lightningAction.setParams({
		"parameters": paramss
	});

lightningAction.setCallback(this, function(response){
		var state = response.getState();														
		if (state === "SUCCESS") {  
			var calloutRes = response.getReturnValue();
			var callBackResponse = JSON.parse(calloutRes);
callBackResponse.data.data.entity = 
                   JSON.stringify(callBackResponse.data.data.entity);
			deferred.resolve(callBackResponse);
		}
		else{	
			deferred.reject('Error');								
		}  							
	});	
						
	$A.enqueueAction(lightningAction);		
	
try{
		$A.getCallback(function() {						
		});
	catch(error){
		log.error("Dummy", "Error " + error);
	}
					
	var promise = deferred.then(function(response) { 
		//Parse the response and build the node object
	}

	return promise;