Package org.apache.rave.model

Examples of org.apache.rave.model.OAuthTokenInfo


    }

    @Test
    @Rollback
    public void testDeleteOAuthTokenInfo() throws Exception {
        OAuthTokenInfo tokenInfo = repository.findOAuthTokenInfo(VALID_USER,
                APP_URL, JpaOAuthTokenInfo.MODULE_ID, TOKEN_NAME, SERVICE_NAME);
        assertNotNull(tokenInfo);
        repository.delete(tokenInfo);
        tokenInfo = repository.findOAuthTokenInfo(VALID_USER,
                APP_URL, JpaOAuthTokenInfo.MODULE_ID, TOKEN_NAME, SERVICE_NAME);
View Full Code Here


    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_existing() {
        final String UPDATED_SERVICE_NAME = "updated service name";
        OAuthTokenInfo oAuthTokenInfo = repository.get(VALID_ID.toString());
        assertThat(oAuthTokenInfo.getServiceName(), is(not(UPDATED_SERVICE_NAME)));
        oAuthTokenInfo.setServiceName(UPDATED_SERVICE_NAME);
        repository.save(oAuthTokenInfo);
        assertThat(repository.get(VALID_ID.toString()).getServiceName(), is(UPDATED_SERVICE_NAME));
    }
View Full Code Here

        repo.setTemplate(template);
    }

    @Test
    public void findOAuthTokenInfo(){
        OAuthTokenInfo info = new OAuthTokenInfoImpl();
        String userId = "1234";
        String appUrl = "www.test.com";
        String moduleId = "2222";
        String tokenName = "token";
        String serviceName = "service";
        info.setUserId(userId);
        info.setAppUrl(appUrl);
        info.setModuleId(moduleId);
        info.setTokenName(tokenName);
        info.setServiceName(serviceName);
        expect(template.findOne(query(where("userId").is(userId)
                .andOperator(where("appUrl").is(appUrl))
                .andOperator(where("moduleId").is(moduleId))
                .andOperator(where("tokenName").is(tokenName))
                .andOperator(where("serviceName").is(serviceName))
View Full Code Here

    }

    @Test
    public void save_null(){
        OAuthTokenInfo info = new OAuthTokenInfoImpl();
        OAuthTokenInfo result;

        template.save(isA(OAuthTokenInfo.class), eq(OAUTH_TOKEN_COLLECTION));
        expectLastCall();
        replay(template);
View Full Code Here

    }

    @Test
    public void save(){
        OAuthTokenInfo item = new OAuthTokenInfoImpl("appUrl", "serviceName",
                "tokenName", "accessToken", "sessionHandle",
                "tokenSecret", "userId", 1111L);
        OAuthTokenInfo result;
        item.setId("1234L");

        template.save(isA(OAuthTokenInfo.class), eq(OAUTH_TOKEN_COLLECTION));
        expectLastCall();

        result = repo.save(item);
        assertNotNull(result.getId());
        assertThat(result.getId(), is(equalTo("1234L")));

    }
View Full Code Here

    }

    @Test
    public void get(){
        OAuthTokenInfo result;
        OAuthTokenInfo item = new OAuthTokenInfoImpl("appUrl", "serviceName",
                "tokenName", "accessToken", "sessionHandle",
                "tokenSecret", "userId", 1111L);
        item.setId("1234L");

        expect(template.findById("1234L", CLASS2, OAUTH_TOKEN_COLLECTION)).andReturn((OAuthTokenInfoImpl)item);
        replay(template);

        result = repo.get("1234L");
View Full Code Here

    }

    @Test
    public void delete(){
        OAuthTokenInfo item = new OAuthTokenInfoImpl("appUrl", "serviceName",
                "tokenName", "accessToken", "sessionHandle",
                "tokenSecret", "userId", 1111L);
        item.setId("1234L");

        template.remove(item);
        expectLastCall();
        expect(template.findById("1234L", CLASS2, OAUTH_TOKEN_COLLECTION)).andReturn((OAuthTokenInfoImpl)item);
        replay(template);
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public TokenInfo getTokenInfo(SecurityToken securityToken, ConsumerInfo consumerInfo, String serviceName,
                                  String tokenName) throws GadgetException {
        OAuthTokenInfo oAuthTokenInfo = tokenInfoService.findOAuthTokenInfo(
                securityToken.getViewerId(), securityToken.getAppUrl(),
                OAuthTokenInfo.MODULE_ID, tokenName, serviceName);
        if (oAuthTokenInfo == null) {
            return null;
        }

        return new TokenInfo(oAuthTokenInfo.getAccessToken(), oAuthTokenInfo.getTokenSecret(),
                oAuthTokenInfo.getSessionHandle(), oAuthTokenInfo.getTokenExpireMillis());
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void setTokenInfo(SecurityToken securityToken, ConsumerInfo consumerInfo, String serviceName,
                             String tokenName, TokenInfo tokenInfo) throws GadgetException {
        OAuthTokenInfo oAuthTokenInfo = new OAuthTokenInfoImpl(securityToken.getAppUrl(),
                serviceName, tokenName, tokenInfo.getAccessToken(), tokenInfo.getSessionHandle(),
                tokenInfo.getTokenSecret(), securityToken.getViewerId(), tokenInfo.getTokenExpireMillis());
        tokenInfoService.saveOAuthTokenInfo(oAuthTokenInfo);
    }
View Full Code Here

    }

    @Test
    public void testFindOAuthTokenInfo() throws Exception {
        OAuthTokenInfo dbOAuthTokenInfo = getOAuthTokenInfo();
        expect(repository.findOAuthTokenInfo(VALID_USER, APP_URL, NOT_USED, TOKEN_NAME, SERVICE_NAME))
                .andReturn(dbOAuthTokenInfo);
        replay(repository);
        OAuthTokenInfo oAuthTokenInfo = service.findOAuthTokenInfo(VALID_USER, APP_URL, NOT_USED,
                TOKEN_NAME, SERVICE_NAME);
        assertNotNull(oAuthTokenInfo);
        assertEquals(APP_URL, oAuthTokenInfo.getAppUrl());

    }
View Full Code Here

TOP

Related Classes of org.apache.rave.model.OAuthTokenInfo

Copyright © 2018 www.massapicom. 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.