m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStateTest.java
blob: b9162b8a0623bdb0e56201d704e029061310968a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package pl.edu.mimuw.cloudatlas.agent.modules;

import org.junit.Test;
import static org.junit.Assert.*;

import pl.edu.mimuw.cloudatlas.model.PathName;
import pl.edu.mimuw.cloudatlas.model.ValueContact;
import pl.edu.mimuw.cloudatlas.model.ValueDuration;
import pl.edu.mimuw.cloudatlas.model.ValueInt;
import pl.edu.mimuw.cloudatlas.model.ValueTime;

public class GossipGirlStateTest {
    @Test
    public void gtpTest1() throws Exception {
        GossipGirlState state = new GossipGirlState(0, new PathName("/"), new ValueContact(null, null), true);
        state.hejkaSendTimestamp = new ValueTime(100l);
        state.hejkaReceiveTimestamp = new ValueTime(110l);
        state.noCoTamSendTimestamp = new ValueTime(120l);
        state.noCoTamReceiveTimestamp = new ValueTime(130l);
        state.computeOffset();
        assertEquals(new ValueDuration(0l), state.offset);
    }

    @Test
    public void gtpTest2() throws Exception {
        GossipGirlState state = new GossipGirlState(0, new PathName("/"), new ValueContact(null, null), true);
        state.hejkaSendTimestamp = new ValueTime(100l);
        state.hejkaReceiveTimestamp = new ValueTime(60l);
        state.noCoTamSendTimestamp = new ValueTime(70l);
        state.noCoTamReceiveTimestamp = new ValueTime(130l);
        state.computeOffset();
        assertEquals(new ValueDuration(-50l), state.offset);
    }

    @Test
    public void gtpTest3() throws Exception {
        GossipGirlState state = new GossipGirlState(0, new PathName("/"), new ValueContact(null, null), true);
        state.hejkaSendTimestamp = new ValueTime(100l);
        state.hejkaReceiveTimestamp = new ValueTime(160l);
        state.noCoTamSendTimestamp = new ValueTime(170l);
        state.noCoTamReceiveTimestamp = new ValueTime(130l);
        state.computeOffset();
        assertEquals(new ValueDuration(50l), state.offset);
    }
}