Package com.sishuok.es.common.plugin.entity

Examples of com.sishuok.es.common.plugin.entity.Move


    }


    @Test
    public void testDownWithMiddle25AndNotFirst() {
        Move first = createMove(); //1000
        Move to = createMove(); //2000
        for (int i = 0; i < 25; i++) {
            createMove();
        }
        Move from = createMove();
        Integer fromWeight = from.getWeight();
        Integer toWeight = to.getWeight();
        Integer firstWeight = first.getWeight();
        flush();

        moveService.down(from.getId(), to.getId());
        from = moveService.findOne(from.getId());
        assertEquals(Integer.valueOf(toWeight - (toWeight - firstWeight) / 2), from.getWeight());
    }
View Full Code Here


    }


    @Test
    public void testDownWithMiddle25AndIsFirst() {
        Move to = createMove(); //1000
        for (int i = 0; i < 25; i++) {
            createMove();
        }
        Move from = createMove();
        Integer fromWeight = from.getWeight();
        Integer toWeight = to.getWeight();
        flush();

        moveService.down(from.getId(), to.getId());
        from = moveService.findOne(from.getId());
        assertEquals(Integer.valueOf(toWeight / 2), from.getWeight());
    }
View Full Code Here


    @Test
    public void testUpWithMiddle25AndNotLast() {

        Move from = createMove(); //2000
        for (int i = 0; i < 25; i++) {
            createMove();
        }
        Move to = createMove();
        Move last = createMove();
        Integer fromWeight = from.getWeight();
        Integer toWeight = to.getWeight();
        Integer lastWeight = last.getWeight();
        flush();

        moveService.up(from.getId(), to.getId());
        from = moveService.findOne(from.getId());
        assertEquals(Integer.valueOf(toWeight + (lastWeight - toWeight) / 2), from.getWeight());
View Full Code Here

    }


    @Test
    public void testUpWithMiddle25AndIsLast() {
        Move from = createMove();
        for (int i = 0; i < 25; i++) {
            createMove();
        }
        Move to = createMove();
        Integer fromWeight = from.getWeight();
        Integer toWeight = to.getWeight();
        flush();

        moveService.up(from.getId(), to.getId());
        from = moveService.findOne(from.getId());
        assertEquals(Integer.valueOf(toWeight + moveService.getStepLength()), from.getWeight());
    }
View Full Code Here

    }

    @Test
    public void testReweight() {
        for (int i = 0; i < 20; i++) {
            Move move = createMove();
            move.setWeight(i);
        }
        flush();

        moveService.reweight();
View Full Code Here

    }


    private Move createMove() {
        Move move = new Move();
        move.setName("zhang" + nextRandom());
        moveService.saveAndFlush(move);
        return move;
    }
View Full Code Here

TOP

Related Classes of com.sishuok.es.common.plugin.entity.Move

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.