Esempio n. 1
0
  @Test
  public void updateDeviceEntry() {
    fakeReceiver.emitSingleCorrectMessage();
    fakeReceiver.emitSingleCorrectMessageDifferentServices();

    assertSame("Correct message not in cache", parser.getCache().size(), 1);
    assertSame("Correct message not in cache", parser.getCache().lastAnnounceSize(), 1);
    assertNull("Original message still in cache", parser.getCache().get(CORRECT_MESSAGE));
    assertNotNull(
        "New message not in cache", parser.getCache().get(CORRECT_MESSAGE_DIFFERENT_SERVICES));
  }
Esempio n. 2
0
  @Test
  public void addDeviceToCacheTest() {
    fakeReceiver.emitSingleCorrectMessage();
    assertSame("Entries in cache != 1", parser.getCache().size(), 1);
    assertSame("Paths in cache != 1", parser.getCache().lastAnnounceSize(), 1);
    assertNotNull("JSON message not in cache", parser.getCache().get(CORRECT_MESSAGE));

    fakeReceiver.emitSingleCorrectMessageDifferentDevice();
    assertSame("Entries in cache != 2", parser.getCache().size(), 2);
    assertSame("Paths in cache != 2", parser.getCache().lastAnnounceSize(), 2);
    assertNotNull("JSON message not in cache", parser.getCache().get(CORRECT_MESSAGE));
    assertNotNull(
        "JSON message not in cache", parser.getCache().get(CORRECT_MESSAGE_DIFFERENT_DEVICE));
  }
Esempio n. 3
0
 @Test
 public void dontAddTwiceTest() {
   fakeReceiver.emitSingleCorrectMessage();
   fakeReceiver.emitSingleCorrectMessage();
   assertSame("Message was added more than once", parser.getCache().size(), 1);
   assertSame("Message was added more than once", parser.getCache().lastAnnounceSize(), 1);
 }
Esempio n. 4
0
 @Test
 public void getFromCacheTest() {
   fakeReceiver.emitSingleCorrectMessage();
   assertNotNull("Correct message not in cache", parser.getCache().get(CORRECT_MESSAGE));
 }
Esempio n. 5
0
 @Before
 public void setUp() {
   this.fakeReceiver = new FakeMessageReceiver();
   this.parser = new AnnounceDeserializer();
   fakeReceiver.addObserver(parser);
 }