Examples of ExternalCompany


Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    public ExternalCompany findUniqueByName(String name)
            throws InstanceNotFoundException {
        Criteria c = getSession().createCriteria(ExternalCompany.class);
        c.add(Restrictions.eq("name", name));

        ExternalCompany found = (ExternalCompany) c.uniqueResult();
        if (found == null) {
            throw new InstanceNotFoundException(name, ExternalCompany.class.getName());
        }

        return found;
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    @Override
    public ExternalCompany findUniqueByNif(String nif) throws InstanceNotFoundException {
        Criteria c = getSession().createCriteria(ExternalCompany.class);
        c.add(Restrictions.eq("nif", nif));

        ExternalCompany found = (ExternalCompany) c.uniqueResult();
        if (found == null) {
            throw new InstanceNotFoundException(nif, ExternalCompany.class.getName());
        }

        return found;
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    }

    @Test
    @Transactional
    public void testSaveExternalCompany() {
        ExternalCompany externalCompany = createValidExternalCompany();
        externalCompanyDAO.save(externalCompany);
        assertTrue(externalCompany.getId() != null);
    }
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    }

    @Test
    @Transactional
    public void testRemoveExternalCompany() throws InstanceNotFoundException {
        ExternalCompany externalCompany = createValidExternalCompany();
        externalCompanyDAO.save(externalCompany);
        externalCompanyDAO.remove(externalCompany.getId());
        assertFalse(externalCompanyDAO.exists(externalCompany.getId()));
    }
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    @Test
    @Transactional
    public void testListExternalCompanies() {
        int previous = externalCompanyDAO.list(ExternalCompany.class).size();
        ExternalCompany externalCompany = createValidExternalCompany();
        externalCompanyDAO.save(externalCompany);
        assertEquals(previous + 1, externalCompanyDAO.list(ExternalCompany.class).size());
    }
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    }

    @Test
    public void testRelationWithUser() throws InstanceNotFoundException {
        final User user = createValidUser();
        final ExternalCompany externalCompany = createValidExternalCompany();
        externalCompany.setCompanyUser(user);

        IOnTransaction<Void> saveEntities = new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                userDAO.save(user);
                externalCompanyDAO.save(externalCompany);
                return null;
            }
        };
        transactionService.runOnTransaction(saveEntities);

        IOnTransaction<Void> retrieveEntitiesInOtherTransaction = new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                try{
                    ExternalCompany retrievedCompany = externalCompanyDAO.find(externalCompany.getId());
                    assertEquals(user.getLoginName(), retrievedCompany.getCompanyUser().getLoginName());
                }
                catch (InstanceNotFoundException e) {
                    fail("Unexpected InstanceNotFoundException");
                }
                return null;
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    }

    @Test
    @Transactional
    public void testFindUniqueByName() throws InstanceNotFoundException {
        ExternalCompany externalCompany = createValidExternalCompany();
        externalCompanyDAO.save(externalCompany);
        assertEquals(externalCompany.getId(),
                externalCompanyDAO.findUniqueByName(externalCompany.getName()).getId());
    }
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

    }

    @Test
    @Transactional
    public void testExistsByName() throws InstanceNotFoundException {
        ExternalCompany externalCompany = createValidExternalCompany();
        assertFalse(externalCompanyDAO.existsByName(externalCompany.getName()));
        externalCompanyDAO.save(externalCompany);
        assertTrue(externalCompanyDAO.existsByName(externalCompany.getName()));
    }
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

        assertTrue(externalCompanyDAO.existsByName(externalCompany.getName()));
    }

    @Test(expected=ValidationException.class)
    public void testUniqueCompanyNameCheck() throws ValidationException {
        final ExternalCompany externalCompany1 = createValidExternalCompany();

        IOnTransaction<Void> createCompanyWithRepeatedName = new IOnTransaction<Void>() {

            @Override
            public Void execute() {
View Full Code Here

Examples of org.libreplan.business.externalcompanies.entities.ExternalCompany

        transactionService.runOnTransaction(createCompanyWithRepeatedName);
    }

    @Test(expected=ValidationException.class)
    public void testUniqueCompanyNifCheck() throws ValidationException {
        final ExternalCompany externalCompany1 = createValidExternalCompany();

        IOnTransaction<Void> createCompany = new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                externalCompanyDAO.save(externalCompany1);
                return null;
            }
        };
        IOnTransaction<Void> createCompanyWithRepeatedNif = new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                ExternalCompany externalCompany2 = createValidExternalCompany();
                externalCompany2.setNif(externalCompany1.getNif());
                externalCompanyDAO.save(externalCompany2);
                return null;
            }
        };
        transactionService.runOnTransaction(createCompany);
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.