/core/src/test/java/com/trackit/server/core/DefaultTrackableUnitQueryDispatcherTests.java
Java | 49 lines | 40 code | 8 blank | 1 comment | 0 complexity | c394a7c067a98851229fc0b6087273ce MD5 | raw file
- package com.trackit.server.core;
-
- import com.google.common.collect.ImmutableCollection;
- import com.google.gson.Gson;
- import org.junit.Assert;
- import org.junit.Ignore;
- import org.junit.Test;
-
- public class DefaultTrackableUnitQueryDispatcherTests {
- @Test
- @Ignore("Requires specific MongoDB setup to run.")
- public void testAddOrUpdateTrackableUnit() throws Exception {
- final TrackableUnitQueryDispatcher testedQueryDispatcher =
- new DefaultTrackableUnitQueryDispatcher();
- final DefaultTrackableUnit addedTrackableUnit =
- new DefaultTrackableUnit("trackableUnit", "imageString");
- testedQueryDispatcher.addOrUpdateTrackableUnit(addedTrackableUnit);
-
- final ImmutableCollection<TrackableUnit> allTrackableUnits =
- testedQueryDispatcher.getAllTrackableUnits();
- Assert.assertEquals(1, allTrackableUnits.size());
- Assert.assertTrue(allTrackableUnits.contains(addedTrackableUnit));
-
- // Ensure that no more entities would be added.
- testedQueryDispatcher.addOrUpdateTrackableUnit(addedTrackableUnit);
- final ImmutableCollection<TrackableUnit> allTrackableUnitsAfterSecondAddition =
- testedQueryDispatcher.getAllTrackableUnits();
-
- Assert.assertEquals(1, allTrackableUnitsAfterSecondAddition.size());
- }
-
- @Test
- @Ignore("Requires specific MongoDB setup to run.")
- public void testJsonEncodingForRetrievedTrackableUnits() throws Exception {
- final TrackableUnitQueryDispatcher testedQueryDispatcher =
- new DefaultTrackableUnitQueryDispatcher();
- final DefaultTrackableUnit addedTrackableUnit =
- new DefaultTrackableUnit("UNIQUE_MARKER", "IMAGE123");
- testedQueryDispatcher.addOrUpdateTrackableUnit(addedTrackableUnit);
-
- final ImmutableCollection<TrackableUnit> allTrackableUnits =
- testedQueryDispatcher.getAllTrackableUnits();
-
- String gson = new Gson().toJson(allTrackableUnits);
- Assert.assertTrue(gson.length() > 0);
- Assert.assertTrue(gson.contains("UNIQUE_MARKER"));
- Assert.assertTrue(gson.contains("IMAGE123"));
- }
- }