• iyappan kandasamy 4
  • NEWBIE
  • 69 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 52
    Replies
Question : Whenever account is created then insert a contact and then when the account field "description" is updated then update the contact description also....

Actually I have got solution seperately...but it would be of great help if it is combined...Thanks

1. Trigger when the account field "description" is updated then update 
    -----------------------------------------------------------------------------------------
     the contact description also..
     --------------------------------------
trigger acc on account(after update)
{
set<id> accids = new set<id>();
for(account a : trigger.new)
{
accids.add(a.id);
}
list<contact> conlist=[select id,account.description, description from contact where accountid=: accids];
for (contact c: conlist)
{
c.description=c.account.description;
}
update conlist;
}

2.  Whenever account is created then insert a contact
      -------------------------------------------------------------------
trigger createcon on account(after insert)
{
list<contact> conlist = new list<contact>();
for (account a:trigger.new)
{
contact c = new contact();
c.lastname= a.name;
c.accountid=a.id;
conlist.add(c);
}
insert conlist;
}

I want to combine the above 2 triggers into one trigger...Any help would be great...Thanks in advance...
how to fetch approver name from approver id in salesforce apex class
In my requirement for the case object...there is 'approval history'...in that I want the 'actual approver' name in my apex class. For this i have written the apex extension class...and in my visual force page i have to stamp this value....

Apex extension class:
-----------------------------
public with sharing class gkrefundrequest
 {
  public Id caseId {get;set;}
  public case caserecord {get;set;}
  public String approver{get;set;}  
  public list<ProcessInstance> lista{get;set;}

  
  public gkrefundrequest(ApexPages.standardController stdController)
  {
  this.caseId = stdController.getId();          //The stdcontroller will get the case record id
  lista = new list<ProcessInstance>();
  lista = [SELECT LastActor.name,TargetObjectId, SubmittedById FROM ProcessInstance WHERE TargetObjectId = '50058000005fGYz' and status='approved']; // for that particualar case this query will fetch approver id
  }  
  }

My visual for page where to stamp the 'actual approver' value is:
------------------------------------------------------------------------------------
<tr>
                    <td><b>Sales Approval:</b></td>
                    <td>{!case.caseid }</td>
                </tr>
                

but the above thing is not working....only im getting the actual approver id....not the actual approver name....

Please kindly need help on the above as it is very very urgent...I have to submit tomorrow...
Thanks in advance...
In my requirement for the case object...there is 'approval history'...in that I want the 'actual approver' name in my apex class. For this i have written the apex extension class...and in my visual force page i have to stamp this value....

Apex extension class:
-----------------------------
public with sharing class gkrefundrequest
 {
  public Id caseId {get;set;}
  public case caserecord {get;set;}
  public String approver{get;set;}  
  public list<ProcessInstance> lista{get;set;}

  
  public gkrefundrequest(ApexPages.standardController stdController)
  {
  this.caseId = stdController.getId();          //The stdcontroller will get the case record id
  lista = new list<ProcessInstance>();
  lista = [SELECT LastActorId,SubmittedById FROM ProcessInstance where Id =: this.caseId]; // for that particualar case this query will fetch approver id
  }  
  }

My visual for page where to stamp the 'actual approver' value is:
------------------------------------------------------------------------------------
<tr>
                    <td><b>Sales Approval:</b></td>
                    <td>{!case.caseid }</td>
                </tr>
                

but the above thing is not working....only im getting the actual approver id....
Please kindly need help on the above as it is urgent...I have to submit tomorrow...
Thanks in advance...
 
This is the original code
-------------------------------
private String addressValidation(Contact con, boolean showApexErroMsg){
            boolean errorExist = false;
            String addrs_Error_Message = '';
            String errorMsgFullString = '';
   
            if (!AddressService.isValidationResultValid(con.Other_Address_Validation_Status__c, con.Other_Address_Validation_Timestamp__c))
            {
                addrs_Error_Message += ' Ship To Address, ';
                errorExist = true;
            }

        if (!AddressService.isValidationResultValid(con.Mailing_Address_Validation_Status__c, con.Mailing_Address_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Sold To Address, ';
            errorExist = true;
        }

        if (!AddressService.isValidationResultValid(con.Other_Address2_Validation_Status__c, con.Other_Address2_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Bill To Address ';
            errorExist = true;
        }

        if(String.isNotBlank(addrs_Error_Message)){
            errorMsgFullString = con.name+' has an non-validated '+addrs_Error_Message+'. Please go to the Contact page for '+con.name +' and validate the address.';
            if(showApexErroMsg)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,errorMsgFullString));

        }
        system.debug('----addressValidation Result ----'+errorExist);
        return errorMsgFullString;
    }

kindly need test class for the above code.
Please do the needful as it is urgent
Thanks in advance
This is original trigger code
------------------------------------
updateQuoteLineItem = new List<QuoteLineItem>();
        for (QuoteLineItem qli : MapQLI.values()) {
            if(mapQuoteOppty.get(qli.Id) != null) {
                String OppID = mapQuoteOppty.get(qli.Id);
                OpportunityLineItem OLI = MapOLI.get(OppID);

                qli.Event__c = OLI.Event__c;
                qli.Opp_Line_Item_Id__c = OLI.Id;
                qli.Opportunity_Line_Item_Name__c = OLI.Name;
                qli.ServiceDate = OLI.ServiceDate;
                qli.Onsite_Additional_Price__c = OLI.Onsite_Additional_Price__c;
                qli.Tax__c = OLI.Tax__c;
                qli.Tax_Rate__c = OLI.Tax_Rate__c;
                qli.Promo_Code__c = OLI.Promo_Code__c;
                updateQuoteLineItem.add(qli);
            }

need test class for the above code.
Kindly do the needful
Thanks in advance
This is the original code for trigger
---------------------------------------------
updateQuoteLineItem = new List<QuoteLineItem>();
        for (QuoteLineItem qli : MapQLI.values()) {
            if(mapQuoteOppty.get(qli.Id) != null) {
                String OppID = mapQuoteOppty.get(qli.Id);
                OpportunityLineItem OLI = MapOLI.get(OppID);

                qli.Event__c = OLI.Event__c;
                qli.Opp_Line_Item_Id__c = OLI.Id;
                qli.Opportunity_Line_Item_Name__c = OLI.Name;
                qli.ServiceDate = OLI.ServiceDate;
                qli.Onsite_Additional_Price__c = OLI.Onsite_Additional_Price__c;
                qli.Tax__c = OLI.Tax__c;
                qli.Tax_Rate__c = OLI.Tax_Rate__c;
                qli.Promo_Code__c = OLI.Promo_Code__c;
                updateQuoteLineItem.add(qli);
            }

Need test class for the above code.
It is very urgent...Please do the needful....Thanks in advance
Testing Apex class
Actually this is the controller class and the help I need is how to write the test class for the below code.

Orginal Apex controller code:
--------------------------------------
private String addressValidation(Contact con, boolean showApexErroMsg){
            boolean errorExist = false;
            String addrs_Error_Message = '';
            String errorMsgFullString = '';
   
            if (!AddressService.isValidationResultValid(con.Other_Address_Validation_Status__c, con.Other_Address_Validation_Timestamp__c))
            {
                addrs_Error_Message += ' Ship To Address, ';
                errorExist = true;
            }

        if (!AddressService.isValidationResultValid(con.Mailing_Address_Validation_Status__c, con.Mailing_Address_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Sold To Address, ';
            errorExist = true;
        }

        if (!AddressService.isValidationResultValid(con.Other_Address2_Validation_Status__c, con.Other_Address2_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Bill To Address ';
            errorExist = true;
        }

        if(String.isNotBlank(addrs_Error_Message)){
            errorMsgFullString = con.name+' has an non-validated '+addrs_Error_Message+'. Please go to the Contact page for '+con.name +' and validate the address.';
            if(showApexErroMsg)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,errorMsgFullString));

        }
        system.debug('----addressValidation Result ----'+errorExist);
        return errorMsgFullString;
    }

Need test class for the above code.
Please do the needful as it is urgent. Thanks in advance.
 
Actually this is the controller class and the help I need is how to write the test class for the below code.

Orginal Apex controller code:
--------------------------------------
private String addressValidation(Contact con, boolean showApexErroMsg){
            boolean errorExist = false;
            String addrs_Error_Message = '';
            String errorMsgFullString = '';
   
            if (!AddressService.isValidationResultValid(con.Other_Address_Validation_Status__c, con.Other_Address_Validation_Timestamp__c))
            {
                addrs_Error_Message += ' Ship To Address, ';
                errorExist = true;
            }

        if (!AddressService.isValidationResultValid(con.Mailing_Address_Validation_Status__c, con.Mailing_Address_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Sold To Address, ';
            errorExist = true;
        }

        if (!AddressService.isValidationResultValid(con.Other_Address2_Validation_Status__c, con.Other_Address2_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Bill To Address ';
            errorExist = true;
        }

        if(String.isNotBlank(addrs_Error_Message)){
            errorMsgFullString = con.name+' has an non-validated '+addrs_Error_Message+'. Please go to the Contact page for '+con.name +' and validate the address.';
            if(showApexErroMsg)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,errorMsgFullString));

        }
        system.debug('----addressValidation Result ----'+errorExist);
        return errorMsgFullString;
    }

Need test class for the above code.
Please do the needful. Thanks in advance
Hi ,

This is my test class for insert a record

Parent Object :Album__c
Child object :Track__c(which has loopup relation with Album__C)

I have written the class and the test class for inserting a record in the child object...but both are giving me error....

In main program
----------------------

public class instrack 
{
track__c al = new track__c(); 
public track__c merch(String name,string name1)  
{
al.Name=name;                             
al.Album__c=name1;
insert al;                 
system.debug('the inserted record is:'+name);
return al;
}
}

Executed as :

instrack mc=new instrack();
mc.merch('Container','GullyBoy');

Error as: Method does not exist  or incorrect signature :void merch(string) from the type instrack....

Test class
-------------
@istest
public class instracktest
{
static testmethod void testmerch()
{
track__c al = new track__c(Name='Surgical'); 
 insert al;   
 Test.startTest();
         al = new track__c (Name = 'Surgical',Album__c='GullyBoy');
         Database.SaveResult result = Database.insert(al, false);
         System.assert(result.getErrors()[0].getMessage().contains('Track already exist with this'));
        Test.stopTest();              

}
}

Error as : System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Album__c]: [Album__c]

Kindly help out on the issue..Thanks in advance...
Hi ,

This is my test class for insert a record

Parent Object :Album__c
Child object :Track__c(which has loopup relation with Album__C)

I have written the class and the test class for inserting a record in the child object...but both are giving me error....

In main program
----------------------

public class instrack 
{
track__c al = new track__c(); 
public track__c merch(String name,string name1)  
{
al.Name=name;                             
al.Album__c=name1;
insert al;                 
system.debug('the inserted record is:'+name);
return al;
}
}

Executed as :

instrack mc=new instrack();
mc.merch('Container','GullyBoy');

Error as: Method does not exist  or incorrect signature :void merch(string) from the type instrack....

Test class
-------------
@istest
public class instracktest
{
static testmethod void testmerch()
{
track__c al = new track__c(Name='Surgical'); 
 insert al;   
 Test.startTest();
         al = new track__c (Name = 'Surgical',Album__c='GullyBoy');
         Database.SaveResult result = Database.insert(al, false);
         System.assert(result.getErrors()[0].getMessage().contains('Track already exist with this'));
        Test.stopTest();              

}
}

Error as : System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Album__c]: [Album__c]

Kindly help out on the issue..Thanks in advance...
I want dump question in Salesforce Administration Certification.
Need latest Salesforce Admin dumps and Salesforce App builder Dumps...Please reply to my email : iyappanonline7@gmail.com....Thanks
Hi,
I have written the apex class for addition of two numbers. but for writing the test class i have issue.
Program is
--------------
public class Add 
{    
public integer a;
public integer b;
public integer c;
public integer addt()
{
    c=a+b; 
    system.debug('the result is'+c);
    return c;
}      
}

My test class
-----------------
@istest
public class Addtest
{
static testmethod void testadd()
{
    Add ad=new Add();
    integer res=ad.addt();
    system.assertEquals(res);
}
}
the test class is throwing error as
"Method does not exist or incorrect signature: void assertEquals(Integer) from the type System"

Any guidance please

Thanks in advance.
In a Picklist field there are LOV's A,B,C
If i select C then the X field to be updated as 0 (zero)
and for other LOV's A and B the X field should be Null and editable.

Note: I have tried using Workflow...but it is not working out....
In the workflow i have give as "AND(ISCHANGED(Country__c),ispickval(Country__c,"India"))" and field update as 0(zero)....but not working
It is Urgent ...Please....

Unexpected token 'Map'. at line 32 column 12
===================================

public with sharing class AccountWeatherController {

    public String city {get;set;}
    public String temp {get;set;}
    public String pressure {get;set;}
    public String humidity {get;set;}
    public String temp_min {get;set;}
    public String temp_max {get;set;}

    public AccountWeatherController(ApexPages.StandardController stdController) {
        Account account = (Account)stdController.getRecord();
        account = [SELECT Id, ShippingCity FROM Account WHERE Id =:account.Id];
        
        String accountCity = account.ShippingCity;
        String apiKey = 'XxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX';

        String requestEndpoint = 'http://api.openweathermap.org/data/2.5/weather';
        requestEndpoint += '?q=' + accountCity;
        requestEndpoint += '&units=metric';
        requestEndpoint += '&APPID=' + apiKey;
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(requestEndpoint);
        request.setMethod('GET');
        HttpResponse response = http.send(request);

        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) {

           // Deserialize the JSON string into collections of primitive data types.
           Map results = (Map) JSON.deserializeUntyped(response.getBody());
           city = String.valueOf(results.get('name'));
           
           Map mainResults = (Map)(results.get('main'));
           temp = String.valueOf(mainResults.get('temp'));
           pressure = String.valueOf(mainResults.get('pressure'));
            humidity = String.valueOf(mainResults.get('humidity')); 
            temp_min = String.valueOf(mainResults.get('temp_min')); 
            temp_max = String.valueOf(mainResults.get('temp_max'));
        
        } else {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'There was an error retrieving the weather information.');
           ApexPages.addMessage(myMsg);
        }
    

    }
}

next to the comments (// Deserialize the JSON string into collections of primitive data types.)

the lines having Map are throwing the above error as "Unexpected token 'Map'. at line 32 column 12"

It would be great to solve the above issue....thanks a lot
          

Want A SalesForce realtime project with solution of sales or marketing or service or anything with solution.
If anybody has project with solution please ping me to iyappanonline7@gmail.com

Thanks in advance
 
1)if 10 records are there for one user can see all the 10 records but another user can see only 4 records
2) how to give permissions to 2 fields for different users who belong to different profiles?

Please any guidance for the above two questions will be greatful ...thanks in advance
From child-Parent soql
----------------------------
Parent = college
child =student(lookup with parent)
relation =Students

written query as

for(Student__c s:[select Name,college__r.Name,CollegeName__c from student__c])
{
  system.debug('student Name:'+s.Name+'     college Name:'+s.college__r.Name);
}

but error as

Line: 3, Column: 18
select Name,college__r.Name,CollegeName__c from ^ ERROR at Row:1:Column:13 Didn't understand relationship 'college__r'
Hi,
one more doubt I have 
For fetching custom object records I have written Apex code as:

Apex class for fetching Bank object custom records
-------------------------------------------------------------------
public class RetBank
{
public void retrievedata()
{
    banks__c[] bk=[select Id,Name from banks__c];
    for(banks__c bnk:bk)
    {
        system.debug('The records are:'+bnk);
    }
}
}

Test class
-------------
@isTest
public class RetBanktest 
{
static testmethod void banks()
{
    RetBank fb=new RetBank();
    fb.retrievedata();
}
}


It is WOrking properly but the test class is giving only 75% ..Y it is not giving 100%....Any guidance please....THanks in advance
Actually this is my apex class for addition of 2 numbers 
public class Addition         //define class
{
  public integer a=5;        //define variables
  public integer b=4;
  public integer c;

  public integer add()               //define function or method
  {
  c=a+b;
  system.debug('the result is '+c);
        return c;
  }
}// end of class


My Test class
----------------
@isTest
public class Additiontest
{
    static testmethod void testadd()
    {
     integer a=5;
     integer b=7;
     integer c=12;
     system.assertEquals(12,12); 
    }  
    
}

and when executing the test class it is showing as pass...

Please need help on this....thanks
Actually this is my apex class for addition of 2 numbers 
public class Addition         //define class
{
  public integer a=5;        //define variables
  public integer b=4;
  public integer c;

  public integer add()               //define function or method
  {
  c=a+b;
  system.debug('the result is '+c);
        return c;
  }
}// end of class


My Test class
----------------
@isTest
public class Additiontest
{
    static testmethod void testadd()
    {
     integer a=5;
     integer b=7;
     integer c=12;
     system.assertEquals(12,12); 
    }  
    
}

and when executing the test class it is showing as pass...

Please need help on this....thanks
Question : Whenever account is created then insert a contact and then when the account field "description" is updated then update the contact description also....

Actually I have got solution seperately...but it would be of great help if it is combined...Thanks

1. Trigger when the account field "description" is updated then update 
    -----------------------------------------------------------------------------------------
     the contact description also..
     --------------------------------------
trigger acc on account(after update)
{
set<id> accids = new set<id>();
for(account a : trigger.new)
{
accids.add(a.id);
}
list<contact> conlist=[select id,account.description, description from contact where accountid=: accids];
for (contact c: conlist)
{
c.description=c.account.description;
}
update conlist;
}

2.  Whenever account is created then insert a contact
      -------------------------------------------------------------------
trigger createcon on account(after insert)
{
list<contact> conlist = new list<contact>();
for (account a:trigger.new)
{
contact c = new contact();
c.lastname= a.name;
c.accountid=a.id;
conlist.add(c);
}
insert conlist;
}

I want to combine the above 2 triggers into one trigger...Any help would be great...Thanks in advance...
Hi...Actually I have written 2 triggers and I need test class for these two triggers...
1. Trigger to update contact description whenever account description is updated with the same value of account description...

trigger acc on account(after update)
{
set<id> accids = new set<id>();
for(account a : trigger.new)
{
accids.add(a.id);
}
list<contact> conlist=[select id,account.description, description from contact where accountid=: accids];
for (contact c: conlist)
{
c.description=c.account.description;
}
update conlist;
}

2.) Whenever account is created then create contact with the account details ...

trigger createcon on account(after insert)
{
list<contact> conlist = new list<contact>();
for (account a:trigger.new)
{
contact c = new contact();
c.lastname= a.name;
c.accountid=a.id;
conlist.add(c);
}
insert conlist;
}


Kindly need test classes for the above 2 triggers. 
Any help on writing the test classes would be of great help....Thanks...
Thanks in advance...
In my requirement for the case object...there is 'approval history'...in that I want the 'actual approver' name in my apex class. For this i have written the apex extension class...and in my visual force page i have to stamp this value....

Apex extension class:
-----------------------------
public with sharing class gkrefundrequest
 {
  public Id caseId {get;set;}
  public case caserecord {get;set;}
  public String approver{get;set;}  
  public list<ProcessInstance> lista{get;set;}

  
  public gkrefundrequest(ApexPages.standardController stdController)
  {
  this.caseId = stdController.getId();          //The stdcontroller will get the case record id
  lista = new list<ProcessInstance>();
  lista = [SELECT LastActorId,SubmittedById FROM ProcessInstance where Id =: this.caseId]; // for that particualar case this query will fetch approver id
  }  
  }

My visual for page where to stamp the 'actual approver' value is:
------------------------------------------------------------------------------------
<tr>
                    <td><b>Sales Approval:</b></td>
                    <td>{!case.caseid }</td>
                </tr>
                

but the above thing is not working....only im getting the actual approver id....
Please kindly need help on the above as it is urgent...I have to submit tomorrow...
Thanks in advance...
 
This is the original code
-------------------------------
private String addressValidation(Contact con, boolean showApexErroMsg){
            boolean errorExist = false;
            String addrs_Error_Message = '';
            String errorMsgFullString = '';
   
            if (!AddressService.isValidationResultValid(con.Other_Address_Validation_Status__c, con.Other_Address_Validation_Timestamp__c))
            {
                addrs_Error_Message += ' Ship To Address, ';
                errorExist = true;
            }

        if (!AddressService.isValidationResultValid(con.Mailing_Address_Validation_Status__c, con.Mailing_Address_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Sold To Address, ';
            errorExist = true;
        }

        if (!AddressService.isValidationResultValid(con.Other_Address2_Validation_Status__c, con.Other_Address2_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Bill To Address ';
            errorExist = true;
        }

        if(String.isNotBlank(addrs_Error_Message)){
            errorMsgFullString = con.name+' has an non-validated '+addrs_Error_Message+'. Please go to the Contact page for '+con.name +' and validate the address.';
            if(showApexErroMsg)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,errorMsgFullString));

        }
        system.debug('----addressValidation Result ----'+errorExist);
        return errorMsgFullString;
    }

kindly need test class for the above code.
Please do the needful as it is urgent
Thanks in advance
This is the original code for trigger
---------------------------------------------
updateQuoteLineItem = new List<QuoteLineItem>();
        for (QuoteLineItem qli : MapQLI.values()) {
            if(mapQuoteOppty.get(qli.Id) != null) {
                String OppID = mapQuoteOppty.get(qli.Id);
                OpportunityLineItem OLI = MapOLI.get(OppID);

                qli.Event__c = OLI.Event__c;
                qli.Opp_Line_Item_Id__c = OLI.Id;
                qli.Opportunity_Line_Item_Name__c = OLI.Name;
                qli.ServiceDate = OLI.ServiceDate;
                qli.Onsite_Additional_Price__c = OLI.Onsite_Additional_Price__c;
                qli.Tax__c = OLI.Tax__c;
                qli.Tax_Rate__c = OLI.Tax_Rate__c;
                qli.Promo_Code__c = OLI.Promo_Code__c;
                updateQuoteLineItem.add(qli);
            }

Need test class for the above code.
It is very urgent...Please do the needful....Thanks in advance
Hi ,

This is my test class for insert a record

Parent Object :Album__c
Child object :Track__c(which has loopup relation with Album__C)

I have written the class and the test class for inserting a record in the child object...but both are giving me error....

In main program
----------------------

public class instrack 
{
track__c al = new track__c(); 
public track__c merch(String name,string name1)  
{
al.Name=name;                             
al.Album__c=name1;
insert al;                 
system.debug('the inserted record is:'+name);
return al;
}
}

Executed as :

instrack mc=new instrack();
mc.merch('Container','GullyBoy');

Error as: Method does not exist  or incorrect signature :void merch(string) from the type instrack....

Test class
-------------
@istest
public class instracktest
{
static testmethod void testmerch()
{
track__c al = new track__c(Name='Surgical'); 
 insert al;   
 Test.startTest();
         al = new track__c (Name = 'Surgical',Album__c='GullyBoy');
         Database.SaveResult result = Database.insert(al, false);
         System.assert(result.getErrors()[0].getMessage().contains('Track already exist with this'));
        Test.stopTest();              

}
}

Error as : System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Album__c]: [Album__c]

Kindly help out on the issue..Thanks in advance...
Hi,
I have written the apex class for addition of two numbers. but for writing the test class i have issue.
Program is
--------------
public class Add 
{    
public integer a;
public integer b;
public integer c;
public integer addt()
{
    c=a+b; 
    system.debug('the result is'+c);
    return c;
}      
}

My test class
-----------------
@istest
public class Addtest
{
static testmethod void testadd()
{
    Add ad=new Add();
    integer res=ad.addt();
    system.assertEquals(res);
}
}
the test class is throwing error as
"Method does not exist or incorrect signature: void assertEquals(Integer) from the type System"

Any guidance please

Thanks in advance.

Unexpected token 'Map'. at line 32 column 12
===================================

public with sharing class AccountWeatherController {

    public String city {get;set;}
    public String temp {get;set;}
    public String pressure {get;set;}
    public String humidity {get;set;}
    public String temp_min {get;set;}
    public String temp_max {get;set;}

    public AccountWeatherController(ApexPages.StandardController stdController) {
        Account account = (Account)stdController.getRecord();
        account = [SELECT Id, ShippingCity FROM Account WHERE Id =:account.Id];
        
        String accountCity = account.ShippingCity;
        String apiKey = 'XxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX';

        String requestEndpoint = 'http://api.openweathermap.org/data/2.5/weather';
        requestEndpoint += '?q=' + accountCity;
        requestEndpoint += '&units=metric';
        requestEndpoint += '&APPID=' + apiKey;
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(requestEndpoint);
        request.setMethod('GET');
        HttpResponse response = http.send(request);

        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) {

           // Deserialize the JSON string into collections of primitive data types.
           Map results = (Map) JSON.deserializeUntyped(response.getBody());
           city = String.valueOf(results.get('name'));
           
           Map mainResults = (Map)(results.get('main'));
           temp = String.valueOf(mainResults.get('temp'));
           pressure = String.valueOf(mainResults.get('pressure'));
            humidity = String.valueOf(mainResults.get('humidity')); 
            temp_min = String.valueOf(mainResults.get('temp_min')); 
            temp_max = String.valueOf(mainResults.get('temp_max'));
        
        } else {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'There was an error retrieving the weather information.');
           ApexPages.addMessage(myMsg);
        }
    

    }
}

next to the comments (// Deserialize the JSON string into collections of primitive data types.)

the lines having Map are throwing the above error as "Unexpected token 'Map'. at line 32 column 12"

It would be great to solve the above issue....thanks a lot
          

From child-Parent soql
----------------------------
Parent = college
child =student(lookup with parent)
relation =Students

written query as

for(Student__c s:[select Name,college__r.Name,CollegeName__c from student__c])
{
  system.debug('student Name:'+s.Name+'     college Name:'+s.college__r.Name);
}

but error as

Line: 3, Column: 18
select Name,college__r.Name,CollegeName__c from ^ ERROR at Row:1:Column:13 Didn't understand relationship 'college__r'
Hi,
one more doubt I have 
For fetching custom object records I have written Apex code as:

Apex class for fetching Bank object custom records
-------------------------------------------------------------------
public class RetBank
{
public void retrievedata()
{
    banks__c[] bk=[select Id,Name from banks__c];
    for(banks__c bnk:bk)
    {
        system.debug('The records are:'+bnk);
    }
}
}

Test class
-------------
@isTest
public class RetBanktest 
{
static testmethod void banks()
{
    RetBank fb=new RetBank();
    fb.retrievedata();
}
}


It is WOrking properly but the test class is giving only 75% ..Y it is not giving 100%....Any guidance please....THanks in advance
Actually this is my apex class for addition of 2 numbers 
public class Addition         //define class
{
  public integer a=5;        //define variables
  public integer b=4;
  public integer c;

  public integer add()               //define function or method
  {
  c=a+b;
  system.debug('the result is '+c);
        return c;
  }
}// end of class


My Test class
----------------
@isTest
public class Additiontest
{
    static testmethod void testadd()
    {
     integer a=5;
     integer b=7;
     integer c=12;
     system.assertEquals(12,12); 
    }  
    
}

and when executing the test class it is showing as pass...

Please need help on this....thanks