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

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


        employeeDAO.delete(2);
    }

    @Test
    public void testRemove() {
        Employee worker1 = new Employee(50);
        employeeDAO.save(worker1);

        assertFalse(employeeDAO.delete(0));
        assertTrue(employeeDAO.delete(1));
        assertFalse(employeeDAO.delete(2));
View Full Code Here


    }

    @Override
    public boolean delete(long id) {
        Map<Long, Entity> storage = EntityStorage.getEntities();
        Entity entity = storage.get(id);
        if (entity == null) {
            return false;
        }
        return storage.remove(id) != null;
    }
View Full Code Here

    }

    @Test
    public void testSave() {

        Redis redis1 = new Redis(50);
        Redis redis2 = new Redis(100);
        Redis redis4 = new Redis(200);
        Redis redis5 = null;
        redis4.setId(4L);
        try {
            redis1 = RedisDAO.save(redis1);
            redis2 = RedisDAO.save(redis2);
            redis4 = RedisDAO.save(redis4);
            redis5 = RedisDAO.save(redis5);
        } catch (UserAlreadyExist e) {
            fail();
        }

        assertEquals(50, redis1.getWeight());
        assertEquals(100, redis2.getWeight());
        assertEquals(200, redis4.getWeight());
        assertEquals(new Long(1), redis1.getId());
        assertEquals(new Long(2), redis2.getId());
        assertEquals(new Long(4), redis4.getId());

        Redis redis11 = RedisDAO.get(1L);
        Redis redis12 = RedisDAO.get(2L);
        Redis redis14 = RedisDAO.get(4L);
        assertEquals(50, redis11.getWeight());
        assertEquals(100, redis12.getWeight());
        assertEquals(200, redis14.getWeight());
        assertEquals(new Long(1), redis11.getId());
        assertEquals(new Long(2), redis12.getId());
        assertEquals(new Long(4), redis14.getId());
        assertTrue(redis5 == null);

        Redis redis3 = new Redis(75);
        redis3.setId(2L);

        try {
            RedisDAO.save(redis3);
            fail();
        } catch (UserAlreadyExist e) {
View Full Code Here

    }

    @Test
    public void testUpdate() {

        Redis redis1 = new Redis(50);
        Redis redis2 = new Redis(100);
        redis2.setId(1L);
        RedisDAO.save(redis1);
        Redis redis3 = RedisDAO.update(redis2);

        assertEquals(new Long(1), redis3.getId());
        assertEquals(100, redis3.getWeight());

        Redis redis4 = new Redis(200);
        try {
            RedisDAO.update(redis4);
            fail();
        } catch (UserNotFound e) {
            assertEquals("null not found!", e.getMessage());
        }

        Redis redis5 = new Redis(201);
        redis5.setId(5L);
        try {
            RedisDAO.update(redis5);
            fail();
        } catch (UserNotFound e) {
            assertEquals("5 not found!", e.getMessage());
View Full Code Here

        RedisDAO.delete(1L);
    }

    @Test
    public void testGet() {
        Redis redis1 = new Redis(50);
        Redis redis2 = new Redis(100);
        RedisDAO.save(redis1);
        RedisDAO.save(redis2);

        Redis redis3 = RedisDAO.get(0);
        assertTrue(redis3 == null);

        Redis redis4 = RedisDAO.get(1);
        assertEquals(new Long(1), redis4.getId());
        assertEquals(50, redis4.getWeight());

        Redis redis5 = RedisDAO.get(2);
        assertEquals(new Long(2), redis5.getId());
        assertEquals(100, redis5.getWeight());

        Redis redis6 = RedisDAO.get(3);
        assertTrue(redis6 == null);

        RedisDAO.delete(1);
        RedisDAO.delete(2);
    }
View Full Code Here

        RedisDAO.delete(2);
    }

    @Test
    public void testRemove() {
        Redis redis1 = new Redis(50);
        RedisDAO.save(redis1);

        assertFalse(RedisDAO.delete(0));
        assertTrue(RedisDAO.delete(1));
        assertFalse(RedisDAO.delete(2));
View Full Code Here

TOP

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

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.