Package com.luxoft.dnepr.courses.regular.unit5.model

Examples of com.luxoft.dnepr.courses.regular.unit5.model.Redis


    }

    @Test
    public void redisDaoTest() {
        //Create 2 redis
        Redis redis1 = new Redis(35);
        Redis redis2 = new Redis(70);
        //Save redis in database
        redis1 = redisDao.save(redis1);
        redis2 = redisDao.save(redis2);
        //Get it from database
        Redis get1 = redisDao.get(redis1.getId());
        Redis get2 = redisDao.get(redis2.getId());
        //Assert redis
        Assert.assertEquals(redis1, get1);
        Assert.assertEquals(redis2, get2);
        //Change salary of employee1
        redis1.setWeight(100);
        redisDao.update(redis1);
        //Check update state
        Redis updated = redisDao.get(redis1.getId());
        Assert.assertEquals(100, updated.getWeight());
    }
View Full Code Here


public class EmployeeDaoImplTest {
    private EmployeeDaoImpl employeeDAO;

    @Before
    public void prepare() {
        employeeDAO = new EmployeeDaoImpl();
    }
View Full Code Here

public class RedisDaoImplTest {
    private RedisDaoImpl RedisDAO;

    @Before
    public void prepare() {
        RedisDAO = new RedisDaoImpl();
    }
View Full Code Here

            id = EntityStorageUtils.getNextToMaxId();
            e.setId(id);
        }
        Map<Long, Entity> storage = EntityStorage.getEntities();
        if (storage.containsKey(id)) {
            throw new UserAlreadyExist(id);
        }
        storage.put(id, e);
        return e;
    }
View Full Code Here

        if (elementId == null) {
            elementId = getNextId();
            element.setId(elementId);
        } else {
            if (getEntities().get(elementId) != null) {
                throw new UserAlreadyExist(elementId + " already exists!");
            }
        }
        getEntities().put(elementId, element);
        return element;
    }
View Full Code Here

        if (e == null) {
            throw new IllegalArgumentException("Argument 'e' can't be a null reference!");
        }
        Long id = e.getId();
        if (id == null) {
            throw new UserNotFound(id);
        }
        Map<Long, Entity> storage = EntityStorage.getEntities();
        if (!storage.containsKey(id)) {
            throw new UserNotFound(id);
        }
        storage.put(id, e);
        return e;
    }
View Full Code Here

        if (element == null) {
            return null;
        }
        Long elementId = element.getId();
        if (elementId == null || getEntities().get(elementId) == null) {
            throw new UserNotFound(elementId + " not found!");
        }
        getEntities().put(elementId, element);
        return element;
    }
View Full Code Here

        EntityStorage.getEntities().put(5L, createEmployee(5L, 5));
    }

    @Test
    public void saveBasicTest() throws UserAlreadyExist {
        Employee emp = createEmployee(null, 1);
        emp = dao.save(emp);
        Assert.assertEquals(new Long(6), emp.getId());

        emp = createEmployee(null, 1);
        emp = dao.save(emp);
        Assert.assertEquals(new Long(7), emp.getId());

        emp = createEmployee(null, 1);
        emp = dao.save(emp);
        Assert.assertEquals(new Long(8), emp.getId());
    }
View Full Code Here

        Assert.assertEquals(new Long(8), emp.getId());
    }

    @Test
    public void saveComplicatedTest() throws UserAlreadyExist {
        Employee emp = createEmployee(null, 1);
        emp = dao.save(emp);
        Assert.assertEquals(new Long(6), emp.getId());

        EntityStorage.getEntities().remove(1L);

        emp = createEmployee(null, 1);
        emp = dao.save(emp);
        Assert.assertEquals(new Long(7), emp.getId());

        EntityStorage.getEntities().remove(2L);
        EntityStorage.getEntities().remove(3L);

        emp = createEmployee(null, 1);
        emp = dao.save(emp);
        Assert.assertEquals(new Long(8), emp.getId());

        EntityStorage.getEntities().remove(7L);
        EntityStorage.getEntities().remove(8L);

        emp = createEmployee(null, 1);
        emp = dao.save(emp);
        Assert.assertEquals(new Long(7), emp.getId());
    }
View Full Code Here

        Assert.assertEquals(new Long(7), emp.getId());
    }

    @Test(expected = UserAlreadyExist.class)
    public void saveAlreadyExistsTest() throws UserAlreadyExist {
        Employee emp = createEmployee(1L, 1);
        dao.save(emp);
    }
View Full Code Here

TOP

Related Classes of com.luxoft.dnepr.courses.regular.unit5.model.Redis

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.