Examples of JpaAuthority


Examples of org.apache.rave.portal.model.JpaAuthority

    }

    @Test
    public void testNoConversion() {
        JpaAuthority template = new JpaAuthority();
        assertThat(converter.convert(template), is(sameInstance(template)));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

        Authority template = new AuthorityImpl();
        template.setAuthority("FOO");
        template.setDefaultForNewUser(true);
        template.addUser(new UserImpl("42"));

        JpaAuthority jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance(template))));
        assertThat(jpaTemplate, is(instanceOf(JpaAuthority.class)));
        assertThat(jpaTemplate.getAuthority(), is(equalTo(template.getAuthority())));
        assertThat(jpaTemplate.isDefaultForNewUser(), is(equalTo(template.isDefaultForNewUser())));
        assertThat(jpaTemplate.getUsers().iterator().next().getId(), is(equalTo(template.getUsers().iterator().next().getId())));

    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

        assertEquals(repository.getType(), JpaAuthority.class);
    }

    @Test
    public void getById_validId() {
        final JpaAuthority authority = (JpaAuthority)repository.get(VALID_ID.toString());
        assertNotNull(authority);
        assertEquals(VALID_ID, authority.getEntityId());
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

    }

    @Test
    public void addOrDeleteAuthorityDoesNotAffectUser() {
        final String authorityName = "guest";
        Authority authority = new JpaAuthority();
        authority.setAuthority(authorityName);
        User user = userRepository.get("1");

        Assert.assertNotNull("User is null", user);
        Assert.assertTrue("User has no authorities", user.getAuthorities().isEmpty());
        assertNull("No authority guest", repository.getByAuthority(authorityName));
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

    public JpaAuthority convert(Authority source) {
        return source instanceof JpaAuthority ? (JpaAuthority) source : createEntity(source);
    }

    private JpaAuthority createEntity(Authority source) {
        JpaAuthority converted = null;
        if (source != null) {
            TypedQuery<JpaAuthority> query = manager.createNamedQuery(JpaAuthority.GET_BY_AUTHORITY_NAME, JpaAuthority.class);
            query.setParameter(JpaAuthority.PARAM_AUTHORITY_NAME, source.getAuthority());
            converted = getSingleResult(query.getResultList());

            if (converted == null) {
                converted = new JpaAuthority();
                updateProperties(source, converted);
            }
        }
        return converted;
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

        return manager.find(JpaAuthority.class, Long.parseLong(id));
    }

    @Override
    public Authority save(Authority item) {
        JpaAuthority authority = converter.convert(item);
        return saveOrUpdate(authority.getEntityId(), manager, authority);
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

        return manager.find(JpaAuthority.class, id);
    }

    @Override
    public Authority save(Authority item) {
        JpaAuthority authority = converter.convert(item);
        return saveOrUpdate(authority.getEntityId(), manager, authority);
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

        return manager.find(JpaAuthority.class, id);
    }

    @Override
    public Authority save(Authority item) {
        JpaAuthority authority = converter.convert(item);
        return saveOrUpdate(authority.getEntityId(), manager, authority);
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

        assertEquals(repository.getType(), JpaAuthority.class);
    }

    @Test
    public void getById_validId() {
        final JpaAuthority authority = (JpaAuthority)repository.get(VALID_ID);
        assertNotNull(authority);
        assertEquals(VALID_ID, authority.getEntityId());
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaAuthority

    }

    @Test
    public void addOrDeleteAuthorityDoesNotAffectUser() {
        final String authorityName = "guest";
        Authority authority = new JpaAuthority();
        authority.setAuthority(authorityName);
        User user = userRepository.get(1L);

        Assert.assertNotNull("User is null", user);
        Assert.assertTrue("User has no authorities", user.getAuthorities().isEmpty());
        assertNull("No authority guest", repository.getByAuthority(authorityName));
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.