Неожиданное исключение нулевого указателя при тестировании

я пишу юнит-тест службы отдыха в Apex

Мой тестовый класс

global class Feedpost9 {

    // your methods here...

    static testMethod void testRest() {
        // set up the request object
        System.RestContext.request = new RestRequest();
        RestContext.request.requestURI = '/v.9/notifications/preferences/ritesh';
        // Invoke the method directly
        Member__c member=new Member__c(name='ritesh');
        insert member;

        Notification_Settings__c no=new Notification_Settings__c(member__c=member.Id);
         no.Event__c='Category|Cloud Foundry' ;
         no.Event_Per_Member__c='12';
         insert no;


        NotificationRestService.retrievingNotificationSettings();

        RestContext.request.requestURI = '/v.9/notifications/preferences' ;

        NotificationRestService.retrievingNotificationSettings();
        RestContext.request.requestURI ='/v.9/notifications/preferences/ritesh.xml';
NotificationRestService.retrievingNotificationSettings();
    }
}

когда тестовый блок достигает в этой точке, то я получил ошибку RestContext.request.requestURI = '/v.9/notifications/preferences ';

        NotificationRestService.retrievingNotificationSettings();

ошибка

System.NullPointerException: попытка отменить ссылку на пустой объект. Class.NotificationRestService.retrievingNotificationSettings: строка 46, столбец 1 Class.Feedpost9.testRest: строка 23, столбец 1

и сегмент, где я получаю эту ошибку

 List note1=[SELECT id,name,Member__r.name,Do_not_Notify__c,Event__c,Event_Per_Member__c,Notification_Method__c from Notification_Settings__c WHERE Member__r.name= :userName Limit 1];
Notification_Settings__c note;

if(note1 !=null )
{if(note1.size() >0)
note=note1.get(0);
}

и ошибка в строке {if (note1.size ()>0) я не могу понять, если note1 не равно нулю, тогда он перейдет к следующей строке, но в следующей строке это дает мне ошибку, почему note1 является нулевым в следующей строке и передается первым, если Statement.query должен вернуть пустой список .please кто-нибудь помогите !!

Ответы на вопрос(1)

Ваш ответ на вопрос