• Shabista Zaidi 5
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi Guys,
Has Anybody  written a test class for the Apex class used in this trailhead below . Apex Class name is EinsteinVision_Admin:

Trailhead 
https://trailhead.salesforce.com/en/content/learn/projects/build-a-cat-rescue-app-that-recognizes-cat-breeds

Below is the Apex Class Snippet:

public class EinsteinVision_Admin {
    @AuraEnabled
    public static void createDatasetFromUrl(String zipUrl) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        service.createDatasetFromUrlAsync(zipUrl);
    }
    @AuraEnabled
    public static List<EinsteinVision_Dataset> getDatasets() {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Dataset[] datasets = service.getDatasets();
        return datasets;
    }
    @AuraEnabled
    public static String trainDataset(Decimal datasetId) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Model model = service.trainDataset(Long.valueOf(String.valueOf(datasetId)), 'Training', 0, 0, '');
        return model.modelId;
    }
    @AuraEnabled
    public static void deleteDataset(Long datasetId) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        service.deleteDataset(datasetId);
    }
    @AuraEnabled
    public static List<EinsteinVision_Model> getModels(Long datasetId) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Model[] models = service.getModels(datasetId);
        return models;
    }
    @AuraEnabled
    public static void getCatPrediction(Id catId, String fileName, String base64) {
        Blob fileBlob = EncodingUtil.base64Decode(base64);
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Dataset[] datasets = service.getDatasets();
        for (EinsteinVision_Dataset dataset : datasets) {
            if (dataset.Name.equals('Einstein_Photos')) {
                EinsteinVision_Model[] models = service.getModels(dataset);
                EinsteinVision_Model model = models.get(0);
                EinsteinVision_PredictionResult result = service.predictBlob(model.modelId, fileBlob, '');
                EinsteinVision_Probability probability = result.probabilities.get(0);
                Claim claim = [SELECT Id FROM Claim WHERE Id=:catId];
                System.debug('===claim ID==='+claim);
                claim.Claim_Accident_Categories__c = probability.label;
                update claim;
                Attachment[] attsOld = [SELECT Id FROM Attachment WHERE ParentId=:catId];
                System.debug('===attachment ID==='+attsOld);
                delete attsOld;
                Attachment att = new Attachment();
                att.Body = fileBlob;
                att.ParentId = claim.Id;
                att.Name = fileName;
                insert att;
            }
        }
    }
    @AuraEnabled
    public static Claim getClaimFields(Id claimId ) {
        Claim claim1 = [SELECT Id,Claim_Accident_Categories__c,Vehicle_Speed_Predicted__c,Likely_Injuries__c,Vehicle_damage__c,Damage_Impact__c FROM Claim WHERE Id=:claimId];
        system.debug('claim1'+claim1);
        return claim1;
    }
    
    @AuraEnabled
    public static List<EinsteinVision_Label> getCatLabels() {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Dataset[] datasets = service.getDatasets();
        for (EinsteinVision_Dataset dataset : datasets) {
            if (dataset.Name.equals('Einstein_Photos')) {
                return dataset.labelSummary.labels;
            }
        }
        return null;
    }
    @AuraEnabled
    public static String getImageUrlFromAttachment(Id catId) {
        List<Attachment> atts = [SELECT Id FROM Attachment WHERE ParentId=:catId];
        System.debug('===id==='+atts);
        if (atts.size()>0) {
            return atts.get(0).Id;
        }
        return '';
    }
}
Hi All!

Have been struggeling with this challange for some time now, 

I´m stuck @ this step

"Update the related Opportunity to reflect the waiver and insurance needs on the Adventure.
Set the 'Needs Insurance' field on the Opportunity to match the 'Needs Insurance' field on the Adventure record.
Set the 'Needs Waiver' field on the Opportunity to match the 'Needs Waiver' field on the Adventure record."

I dont understand how I can do this, is it possible to select the Needs Waiver and Needs Insurance from the Opportunity record here? I´m not able to.
Has anyone completed this trail? I am stomped on challenge number 3, regarding created the process for fulfillment. Any pointers or guidance would be appreciated.
 
Hi,
Test Push notification from connected app successfully sends alert, sound, badge to my IOS device. But Notification using apex code & connected app is not sending any notifications to my IOS Device.

any one help me