Package org.libreplan.ws.typeofworkhours.api

Examples of org.libreplan.ws.typeofworkhours.api.TypeOfWorkHoursDTO


    @Test
    @Transactional
    public void testAddAndGetTypeOfWorkHours() {

        // Missing TypeOfWorkHours name.
        TypeOfWorkHoursDTO cc1 = new TypeOfWorkHoursDTO(null, true,
                new BigDecimal(5));
        // Valid TypeOfWorkHours DTO without hour cost
        TypeOfWorkHoursDTO cc2 = new TypeOfWorkHoursDTO("codeB", "cc2", true,
                new BigDecimal(5));

        /* TypeOfWorkHours list. */
        TypeOfWorkHoursListDTO typeOfWorkHoursListDTO = createTypeOfWorkHoursListDTO(
                cc1, cc2);
View Full Code Here


    @Test
    public void testUpdateTypeOfWorkHours() throws InstanceNotFoundException {

        // First one it creates valid type of work hours

        final TypeOfWorkHoursDTO cc1 = new TypeOfWorkHoursDTO(
                "newTypeOfWorkHours", true, new BigDecimal(5));
        TypeOfWorkHoursListDTO typeOfWorkHoursListDTO = createTypeOfWorkHoursListDTO(cc1);

        List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = typeOfWorkHoursService
                .addTypeOfWorkHours(typeOfWorkHoursListDTO).instanceConstraintViolationsList;
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                typeOfWorkHoursDAO.flush();
                return null;
            }
        });

        /* Test. */
        assertTrue(instanceConstraintViolationsList.toString(),
                instanceConstraintViolationsList.size() == 0);
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                assertTrue(typeOfWorkHoursDAO.existsByCode(cc1.code));
                return null;
            }
        });

        final TypeOfWorkHours typeOfWorkHours = transactionService
                .runOnTransaction(new IOnTransaction<TypeOfWorkHours>() {
                    @Override
                    public TypeOfWorkHours execute() {
                        try {
                            return typeOfWorkHoursDAO.findByCode(cc1.code);
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });

        assertTrue(typeOfWorkHours.getName().equalsIgnoreCase(
                "newTypeOfWorkHours"));
        assertTrue(typeOfWorkHours.getEnabled());
        assertTrue(typeOfWorkHours.getDefaultPrice().compareTo(
                new BigDecimal(5)) == 0);

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                typeOfWorkHoursDAO.flush();
                sessionFactory.getCurrentSession().evict(typeOfWorkHours);
                return null;
            }
        });

        typeOfWorkHours.dontPoseAsTransientObjectAnymore();

        // Update the previous type of work hours
        TypeOfWorkHoursDTO cc2 = new TypeOfWorkHoursDTO(cc1.code, "updateCC1",
                false, new BigDecimal(100));

        typeOfWorkHoursListDTO = createTypeOfWorkHoursListDTO(cc2);

        instanceConstraintViolationsList = typeOfWorkHoursService
View Full Code Here

    private TypeOfWorkHoursConverter() {
    }

    public final static TypeOfWorkHoursDTO toDTO(TypeOfWorkHours typeOfWorkHours) {
        return new TypeOfWorkHoursDTO(typeOfWorkHours.getCode(),
                typeOfWorkHours.getName(), typeOfWorkHours.getEnabled(),
                typeOfWorkHours.getDefaultPrice());

    }
View Full Code Here

TOP

Related Classes of org.libreplan.ws.typeofworkhours.api.TypeOfWorkHoursDTO

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.