• Stephen Stanley 2
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hi All,

I receive the following error when attempting to check the challenge for Apply Unit of Work

Challenge Not yet complete... here's what's wrong: 
The 'challangeComplete' method in the 'UnitOfWorkTest' class has not successfully passed all tests. Ensure that you run the tests and it passes successfully before attempting this challenge again.

However, when I run my code in Developer Console, my test passes.  Any ideas on the problem?  Here is the code:

@isTest
public class UnitOfWorkTest {
    @isTest static void challengeComplete(){
        fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(
            new Schema.SObjectType[]{
                Account.SObjectType,
                Contact.SObjectType,
                Note.SObjectType
            }
        );
        
        for (Integer i=0 ; i<100 ; i++) {
            Account a = new Account(Name= 'Test' + i);
            uow.registerNew(a);
            
            for (Integer j=0 ; j<5 ; j++) {
                Contact c = new Contact(LastName = 'Test'+i + ' ' +j);
                uow.registerNew(c, Contact.AccountId, a);
                
                Note n = new Note(Body='Test '+i + '' + j, Title='Test'+i+j);
                uow.registerRelationship(n, Note.ParentId, a);
                uow.registerNew(n, Note.ParentId, a);
            }
        }

        uow.commitWork();
 
        fflib_SObjectUnitOfWork uow2 = new fflib_SObjectUnitOfWork(
            new Schema.SObjectType[]{
                Account.SObjectType,
                Contact.SObjectType,
                Note.SObjectType
            }
        );        
        for (Account a : [SELECT Id, Name, (SELECT Id, LastName FROM Contacts), (SELECT Id, ParentId, Title, Body FROM Notes) FROM Account]) {
            a.Name = 'Test';
            uow2.registerDirty(a);
            
            Integer i = 0;
            for (Contact c : a.Contacts) {
                c.LastName = 'Test';
                uow2.registerDirty(c);
                
                a.Notes[i].Body='Test';
                uow2.registerDirty(a.Notes[i]);
                i++;
            }
        }        
        
        test.startTest();
        uow2.commitWork();
        test.stopTest();
        
        System.assertEquals(100, [Select Id from Account].size());
        System.assertEquals(500, [Select Id from Contact].size());
        System.assertEquals(500, [Select Id from Note].size());
    }
}
Hi All,

I receive the following error when attempting to check the challenge for Apply Unit of Work

Challenge Not yet complete... here's what's wrong: 
The 'challangeComplete' method in the 'UnitOfWorkTest' class has not successfully passed all tests. Ensure that you run the tests and it passes successfully before attempting this challenge again.

However, when I run my code in Developer Console, my test passes.  Any ideas on the problem?  Here is the code:

@isTest
public class UnitOfWorkTest {
    @isTest static void challengeComplete(){
        fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(
            new Schema.SObjectType[]{
                Account.SObjectType,
                Contact.SObjectType,
                Note.SObjectType
            }
        );
        
        for (Integer i=0 ; i<100 ; i++) {
            Account a = new Account(Name= 'Test' + i);
            uow.registerNew(a);
            
            for (Integer j=0 ; j<5 ; j++) {
                Contact c = new Contact(LastName = 'Test'+i + ' ' +j);
                uow.registerNew(c, Contact.AccountId, a);
                
                Note n = new Note(Body='Test '+i + '' + j, Title='Test'+i+j);
                uow.registerRelationship(n, Note.ParentId, a);
                uow.registerNew(n, Note.ParentId, a);
            }
        }

        uow.commitWork();
 
        fflib_SObjectUnitOfWork uow2 = new fflib_SObjectUnitOfWork(
            new Schema.SObjectType[]{
                Account.SObjectType,
                Contact.SObjectType,
                Note.SObjectType
            }
        );        
        for (Account a : [SELECT Id, Name, (SELECT Id, LastName FROM Contacts), (SELECT Id, ParentId, Title, Body FROM Notes) FROM Account]) {
            a.Name = 'Test';
            uow2.registerDirty(a);
            
            Integer i = 0;
            for (Contact c : a.Contacts) {
                c.LastName = 'Test';
                uow2.registerDirty(c);
                
                a.Notes[i].Body='Test';
                uow2.registerDirty(a.Notes[i]);
                i++;
            }
        }        
        
        test.startTest();
        uow2.commitWork();
        test.stopTest();
        
        System.assertEquals(100, [Select Id from Account].size());
        System.assertEquals(500, [Select Id from Contact].size());
        System.assertEquals(500, [Select Id from Note].size());
    }
}
Got Error  while implementing the lightning application for trailhead module "Connect to salesforce with server side controllers":
Error: Something has gone wrong. Error during init [TypeError: Cannot read property 'apply' of undefined] . Please try again.

Please help below is the Code, Pls help

CampingApp.app:
<aura:application >
	
    <ltng:require styles="{!$Resource.SLDS203 +
         '/assets/styles/salesforce-lightning-design-system.css'}"/>
    
    <div class="slds">
       
        <!-- This component is the real "app" -->
        <c:campingList />
       
    </div>
    
    
</aura:application>

CampingList.cmp:
<aura:component controller="CampingListController" >
    
    <aura:handler name="this" action="{!c.doInit}" value="{!this}"/>
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{'sobjectType': 'Camping_Item__c',
                             'Price__c':0,
                             'quantity':0},
                             'Packed__c':false,
                             'Name':''}"/>
    <!--aura:attribute type="camping_item__c[]" name="items"/-->
        <aura:attribute name="items" type="Camping_Item__c[]"/>

    
    <!-- PAGE HEADER -->
    <div class="slds-page-header" role="banner">
      <div class="slds-grid">
        <div class="slds-col">
          <p class="slds-text-heading--label">Campings</p>
          <h1 class="slds-text-heading--medium">My Campings</h1>
        </div>
      </div>
    </div>
    <!-- / PAGE HEADER -->
    
    <!-- NEW Campign FORM -->
    <div class="slds-col slds-col--padded slds-p-top--large">


          
  <div aria-labelledby="CampingForm">

  <!-- BOXED AREA -->
  <fieldset class="slds-box slds-theme--default slds-container--small">

    <legend id="CampingForm" class="slds-text-heading--small 
      slds-p-vertical--medium">
      Add Camping
    </legend>

    <!-- CREATE NEW EXPENSE FORM -->
    <form class="slds-form--stacked">

      <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="campingName" label="Camping Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Name}"
                  required="true"/>
          </div>
     </div>

     <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="Price" label="Price"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Price__c}"
                  required="true"/>

          </div>
      </div>

      
      <div class="slds-form-element">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="quantity" label="Quantity"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Quantity__c}"
                  required="true"/>
          </div>
      </div>

      <div class="slds-form-element">
          <ui:inputCheckbox aura:id="packed" label="Packed?"
              class="slds-checkbox"
              labelClass="slds-form-element__label"
              value="{!v.newItem.Packed__c}"/>
      </div>

      <div class="slds-form-element">
          <ui:button label="Create Campign"
              class="slds-button slds-button--brand"
              press="{!c.clickCreateCamping}"/>
      </div>

    </form>
    <!-- / CREATE NEW EXPENSE FORM -->

  </fieldset>
  <!-- / BOXED AREA -->

</div>
        </div>
    
    
    
    <div class="slds-col slds-col--padded slds-p-top--large">
    <aura:iteration items="{!v.items}" var="item">
      <c:campingListItem item="{!item}"/>
        </aura:iteration>
    </div>
    
    
    
</aura:component>

CampingListController.js:
({
    
    // Load expenses from Salesforce
doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state == "SUCCESS") {
            console.log("Result: " + response.getReturnValue());
            component.set("v.items", response.getReturnValue());
        }
        else {
            console.log("Failed with state: " + state);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
},
    
    
    
    clickCreateCamping: function(component, event, helper) {

        // Simplistic error checking
        var validCamping = true;

        // Name must not be blank
        var nameField = component.find("campingName");
        var campname = nameField.get("v.value");
        
        if ($A.util.isEmpty(campname)){
            validCamping = false;
            nameField.set("v.errors", [{message:"Camping name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        if ($A.util.isEmpty(component.find("quantity").get("v.value"))){
            validCamping = false;
            component.find("quantity").set("v.errors", [{message:"Camping Quantity can't be blank."}]);
        }
        else {
            component.find("quantity").set("v.errors", null);
        }
        if ($A.util.isEmpty(component.find("Price").get("v.value"))){
            validCamping = false;
            component.find("Price").set("v.errors", [{message:"Camping Price can't be blank."}]);
        }
        else {
            component.find("Price").set("v.errors", null);
        }
        
        

        // ... hint: more error checking here ...

        // If we pass error checking, do some real work
        if(validCamping){
            // Create the new expense
            
            var newCampignItem = Component.get("v.newItem");
            helper.createItem(component, newCampignItem);
        }
    }
})

CampingListController.aspx:
public class CampingListController {

    @auraEnabled
    Public static list<Camping_Item__c> getItems(){
        
        return [select Name, Quantity__c, Price__c, Packed__c from Camping_Item__c];
        
    }
    
    @auraEnabled
    Public static Camping_Item__c saveItem (Camping_Item__c Camping){
        
        upsert Camping;
        return Camping;
        
    }
    
}

CampingListHelper:
({
	createItem : function(component, campingItem) {
		var action = component.get("c.saveItem");
        action.setParams({"Camping", campignItem});
                          
                          action.setCallback(this, function(response){
                          var state = response.getState();
        				if (component.isValid() && state === "SUCCESS") {
            				var items = component.get("v.Items");
            				expenses.push(response.getReturnValue());
            				component.set("v.Items", items);
                         }
                         });
                          $A.enqueueAction(action);
        
	}
})



 
Hi,
the challenge is as follows :

Create a camping component that contains a campingHeader and a campingList component.
1.The campingList component contains an ordered list of camping supplies that include Bug Spray, Bear Repellant, and Goat Food.
2.The campingHeader component contains an H1 heading style with a font size of 18 points and displays 'Camping List'.

so i made a lightening application named "camping.app" having code :

<aura:application >
    <br/><br/><br/>
    <c:campingHeader/>
    <c:campingList/>  
</aura:application>


where lightening component "campingHeader.cmp" having code :

<aura:component >
    <h1> Camping List </h1>
</aura:component>

for I have "campingHeader.css" having code :
.THIS {
}

h1.THIS {
    font-size: 18px;
}

and lightening component "campingList.cmp" having code :

<aura:component >
    <ol>
       <li>Bug Spray</li>
       <li>Bear Repellant</li>
       <li>Goat Food</li>      
    </ol>
</aura:component>

when i preview the application it is working nice; but when checking the challenge it says :
"Challenge Not yet complete... here's what's wrong: 
The 'camping' Lightning Component does not include either the campingHeader or campingList component."

please help me know where I m doing wrong. Thanx waiting for your reply
I'm having problems with this Trailhead:
https://developer.salesforce.com/trailhead/mobile_sdk_native_ios/mobilesdk_ios_getting_started

I have followed the instructions for running "forceios create" and opened the project in XCode. When I run/build the project I get this error:

ld: library not found for -lCocoaLumberjack
clang: error: linker command failed with exit code 1 (use -v to see invocation)


I'm on OS X 10.11.2 (El Capitan), using Xcode 7.2.