package com.github.ssindelar.ps2parser;

import static org.fest.assertions.api.Assertions.assertThat;

import org.testng.annotations.Test;

import com.github.ssindelar.ps2parser.data.world.WorldResponse;
import com.github.ssindelar.ps2parser.data.world.status.ApiWorldStatus;
import com.github.ssindelar.ps2parser.data.world.status.WorldStatusResponds;

public class WorldDaoTest {

	private final WorldApiDAO dao = TestData.API_CONNECTION.getWorldDao();

	@Test
	public void getAllWorlds() {
		WorldResponse worldResponse = this.dao.getAllWorlds();
		assertThat(worldResponse).isNotNull();
		assertThat(worldResponse.getWorlds().size()).isEqualTo(worldResponse.getReturned());
	}

	@Test
	public void getStatusAllWorlds() {
		WorldStatusResponds statusResponse = this.dao.getStatusAllWorlds();
		assertThat(statusResponse).isNotNull();
		assertThat(statusResponse.getAdditionalProperties()).isEmpty();
		assertThat(statusResponse.getWorlds().size()).isEqualTo(statusResponse.getReturned());
		for (ApiWorldStatus worldStatus : statusResponse.getWorlds()) {
			assertThat(worldStatus.getAdditionalProperties()).isEmpty();
			assertThat(worldStatus.getLastReported()).isNotNull();
			assertThat(worldStatus.getGame()).isNotNull().isEqualTo("ps2");
		}
	}
}
