@Test
public void testMapFilter() {
Long waitingTime = 1000L;
File battleImageFile = getDefaultImage();
UniqueID battleId = null;
try {
battleId = createBattle("new battle", battleImageFile);
} catch (IOException e) {
fail("fail to create battle");
}
MapBean mapFiltered = CampaignClient.getInstance().getBean(battleId,
waitingTime);
int width = mapFiltered.getWidth();
int height = mapFiltered.getHeight();
try {
BufferedImage targetImages = ImageIO.read(battleImageFile);
int expectedWidth = targetImages.getWidth();
int expectedHeight = targetImages.getHeight();
assertEquals("width should be same", width, expectedWidth);
assertEquals("height should be same", height, expectedHeight);
// Test filter
double compareZoomFactor = 2.75;
ManualMapFilter filter = new ManualMapFilter(battleId);
filter.showPolygon(new Polygon(new int[] { 5, 25, 25, 5 },
new int[] { 5, 5, 25, 25 }, 4));
filter.hidePolygon(new Polygon(new int[] { 5, 25, 25, 5 },
new int[] { 5, 5, 25, 25 }, 4));
CampaignClient.getInstance().addBean(filter);
UniqueID filterId = filter.getId();
mapFiltered.setFilter(filterId);
filter = CampaignClient.getInstance()
.getBean(filterId, waitingTime);