Examples of GDataAccount


Examples of org.apache.lucene.gdata.data.GDataAccount

     * Test method for 'org.apache.lucene.gdata.servlet.handler.AbstractFeedHandler.createRequestedAccount(HttpServletRequest)'
     */
    public void testCreateRequestedAccount() throws IOException, ParseException, ServiceException {
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest
                .getParameter(AbstractFeedHandler.PARAMETER_ACCOUNT), this.accountName);
        GDataAccount a = new GDataAccount();
        a.setName("helloworld");
        this.adminServiceMockControl.expectAndReturn(this.adminService.getAccount(this.accountName),a );
        this.requestMockControl.replay();
        this.adminServiceMockControl.replay();
        AbstractFeedHandler handler = new InsertFeedHandler();
        try{
           
            GDataAccount account = handler.createRequestedAccount(this.mockRequest);
      
        assertEquals(a,account);
       
        }catch (Exception e) {
            e.printStackTrace();
            fail("unexpected exception -- "+e.getMessage());
           
        }
        this.requestMockControl.verify();
        this.requestMockControl.reset();
        this.adminServiceMockControl.verify();
        this.adminServiceMockControl.reset();
       
        /*
         *Test for service exception
         */
       
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest
                .getParameter(AbstractFeedHandler.PARAMETER_ACCOUNT), this.accountName);
       
        a.setName("helloworld");
        this.adminServiceMockControl.expectAndDefaultThrow(this.adminService.getAccount(this.accountName),new ServiceException(GDataResponse.BAD_REQUEST) );
        this.requestMockControl.replay();
        this.adminServiceMockControl.replay();
         handler = new InsertFeedHandler();
        try{
           
            GDataAccount account = handler.createRequestedAccount(this.mockRequest);
      
            fail(" exception expected ");
       
        }catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

     */
    public static GDataAccount buildEntity(final Document doc){
        if(doc == null)
            return null;
       
        GDataAccount user = new GDataAccount();
        user.setName(doc.get(FIELD_ACCOUNTNAME));
        user.setPassword(doc.get(FIELD_PASSWORD));
        user.setAuthorname(doc.get(FIELD_AUTHORNAME));
        user.setAuthorMail(doc.get(FIELD_AUTHORMAIL));
        try{
        user.setRolesAsInt(Integer.parseInt(doc.get(FIELD_ROLES)));
        }catch (NumberFormatException e) {
            LOG.info("Can't parse userroles: "+user.getName()+" throws NumberFormatException. -- skipping --",e);
        }
        try {
            if(doc.get(FIELD_AUTHORHREF)!= null)
                user.setAuthorLink(new URL(doc.get(FIELD_AUTHORHREF)));
        } catch (MalformedURLException e) {
            LOG.info("SPECIFIED URL for user: "+user.getName()+" throws MalformedURLException. -- skipping --",e);
        }
        return user;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.