• andrew1.3889672359072202E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
We are using the ajax proxy to GET text files and images stored on Amazon S3 into Javascript in a VF page. We get the text files ok, but the image files (png, jpg) arrive slightly mangled. By inspecting connection.js, we see that the proxy handles only two mimeTypes: text/plain and text/xml. Does that mean we can't use it to retrieve images?
I have the following simple visualforce extension, but I'm having a hard time getting the test method to asert properly. Here's the class.

public class extUserProduct{

    private final User_Product__c UserProduct;
    List<User_Product__c> lstUserProduct;
    Contact UserProductNew;
   
    public extUserProduct(ApexPages.StandardSetController controller) {
       
        lstUserProduct = (List<User_Product__c>)[Select Name, Id, Custom_User_Fee__c, Custom_Currency_Code__c,
                                Contact_Full_Name__c, Billing_Start_Date__c, Active_Start_Date__c, Contact__c,Product__c, Product_Provisioning_Date__c
                                From User_Product__c
                                where Product_Setup_Complete__c=FALSE AND Contact__c=:ApexPages.currentPage().getParameters().get('id')];  
      
        UserProductNew = [Select Id, Name From Contact Where Id =: ApexPages.currentPage().getParameters().get('id')];

    }

    public List<User_Product__c> getlstUserProduct(){
        return lstUserProduct;
    }
    public Contact getUserProductNew(){
        return UserProductNew;
    }
   
    public PageReference save() {
    try{
            update lstUserProduct;
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
           
            return Null;
        }
            return (new ApexPages.StandardController(UserProductNew)).view();
    }        
}

I've started my test, but can't figure out how to assert the class to get any test coverage. Here's the test so far.
 
@isTest private class TestUserProd {

    static testMethod void TestUserProd() {
       
        City__c ct = new City__c(name='Toronto');
        insert ct;
       
        Account a = new Account(name='Test', Type='Customer');
        insert a;

        Contact c = new Contact(AccountID=a.id, FirstName='Test', LastName='Test', phone='555-555-5555');
        insert c;
       
        User_Product__c up = new User_Product__c(Account__c=a.id, Contact__c=c.id, Product__c='Product');
        insert up;
       
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
       
        User u = new User(Alias = 'standt', Email='standarduser@test.com',
        EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
        LocaleSidKey='en_US', ProfileId = p.Id,
        TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@test.com');
        insert u;
       
        System.runAs(u) {
                PageReference pageRef         = Page.ProductUpdate;
                    Test.setCurrentPageReference(pageRef);
                    ApexPages.currentPage().getParameters().put('contactId', c.Id);
    
            }
       
    }
}

Thoughts?
We are using the ajax proxy to GET text files and images stored on Amazon S3 into Javascript in a VF page. We get the text files ok, but the image files (png, jpg) arrive slightly mangled. By inspecting connection.js, we see that the proxy handles only two mimeTypes: text/plain and text/xml. Does that mean we can't use it to retrieve images?
I have the following simple visualforce extension, but I'm having a hard time getting the test method to asert properly. Here's the class.

public class extUserProduct{

    private final User_Product__c UserProduct;
    List<User_Product__c> lstUserProduct;
    Contact UserProductNew;
   
    public extUserProduct(ApexPages.StandardSetController controller) {
       
        lstUserProduct = (List<User_Product__c>)[Select Name, Id, Custom_User_Fee__c, Custom_Currency_Code__c,
                                Contact_Full_Name__c, Billing_Start_Date__c, Active_Start_Date__c, Contact__c,Product__c, Product_Provisioning_Date__c
                                From User_Product__c
                                where Product_Setup_Complete__c=FALSE AND Contact__c=:ApexPages.currentPage().getParameters().get('id')];  
      
        UserProductNew = [Select Id, Name From Contact Where Id =: ApexPages.currentPage().getParameters().get('id')];

    }

    public List<User_Product__c> getlstUserProduct(){
        return lstUserProduct;
    }
    public Contact getUserProductNew(){
        return UserProductNew;
    }
   
    public PageReference save() {
    try{
            update lstUserProduct;
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
           
            return Null;
        }
            return (new ApexPages.StandardController(UserProductNew)).view();
    }        
}

I've started my test, but can't figure out how to assert the class to get any test coverage. Here's the test so far.
 
@isTest private class TestUserProd {

    static testMethod void TestUserProd() {
       
        City__c ct = new City__c(name='Toronto');
        insert ct;
       
        Account a = new Account(name='Test', Type='Customer');
        insert a;

        Contact c = new Contact(AccountID=a.id, FirstName='Test', LastName='Test', phone='555-555-5555');
        insert c;
       
        User_Product__c up = new User_Product__c(Account__c=a.id, Contact__c=c.id, Product__c='Product');
        insert up;
       
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
       
        User u = new User(Alias = 'standt', Email='standarduser@test.com',
        EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
        LocaleSidKey='en_US', ProfileId = p.Id,
        TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@test.com');
        insert u;
       
        System.runAs(u) {
                PageReference pageRef         = Page.ProductUpdate;
                    Test.setCurrentPageReference(pageRef);
                    ApexPages.currentPage().getParameters().put('contactId', c.Id);
    
            }
       
    }
}

Thoughts?