Resources information on planet list
* Added resource information records to the planet list's response. * Added a database view and the corresponding row mapper and DAO method which can be used as the data source for the planet list's resource information. For now this view always returns 0 for both civilian and military investments. * Added new tab to display resource information on the planet list page. The old version of the economy tab will be kept until the corresponding data no longer exists. * The following SQL scripts must be re-executed to upgrade a database: -> 040-functions/167-planet-list.sql
This commit is contained in:
parent
bf6bea5a79
commit
96670d45be
15 changed files with 1079 additions and 31 deletions
legacyworlds-server-tests/src/test/java/com/deepclone/lw/beans/game/resources
|
@ -0,0 +1,91 @@
|
|||
package com.deepclone.lw.beans.game.resources;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.deepclone.lw.cmd.player.gdata.PlanetListResourceRecord;
|
||||
import com.deepclone.lw.testing.MockResultSet;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tests for the {@link PlanetListResourceRecordMapper}
|
||||
*
|
||||
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
|
||||
*/
|
||||
public class TestPlanetListResourceRecordMapper
|
||||
{
|
||||
|
||||
/** Planet identifier value */
|
||||
private static final int TEST_PLANET_ID = 1;
|
||||
|
||||
/** Income value */
|
||||
private static final long TEST_INCOME = 2L;
|
||||
|
||||
/** Upkeep value */
|
||||
private static final long TEST_UPKEEP = 3L;
|
||||
|
||||
/** Civilian investment value */
|
||||
private static final long TEST_CIV_INVESTMENT = 4L;
|
||||
|
||||
/** Military investment value */
|
||||
private static final long TEST_MIL_INVESTMENT = 5L;
|
||||
|
||||
/** Fake result set used as the data source */
|
||||
private ResultSet data;
|
||||
|
||||
/** Row mapper to test */
|
||||
private PlanetListResourceRecordMapper mapper;
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the row mapper as well as the fake result set
|
||||
*/
|
||||
@Before
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void setUp( )
|
||||
{
|
||||
HashMap< String , Object > row = new HashMap< String , Object >( );
|
||||
row.put( "planet_id" , TEST_PLANET_ID );
|
||||
row.put( "pres_income" , TEST_INCOME );
|
||||
row.put( "pres_upkeep" , TEST_UPKEEP );
|
||||
row.put( "civ_investment" , TEST_CIV_INVESTMENT );
|
||||
row.put( "mil_investment" , TEST_MIL_INVESTMENT );
|
||||
|
||||
this.data = MockResultSet.create( new HashMap[] {
|
||||
row
|
||||
} );
|
||||
|
||||
this.mapper = new PlanetListResourceRecordMapper( );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try mapping a row
|
||||
*/
|
||||
@Test
|
||||
public void testMapRow( )
|
||||
throws SQLException
|
||||
{
|
||||
this.data.absolute( 1 );
|
||||
|
||||
FullPlanetListRecord fullRecord = this.mapper.mapRow( this.data , 1 );
|
||||
assertEquals( TEST_PLANET_ID , fullRecord.getPlanetId( ) );
|
||||
|
||||
PlanetListResourceRecord record = fullRecord.getRecord( );
|
||||
assertNotNull( record );
|
||||
assertEquals( TEST_INCOME , record.getIncome( ) );
|
||||
assertEquals( TEST_UPKEEP , record.getUpkeep( ) );
|
||||
assertEquals( TEST_CIV_INVESTMENT , record.getCivInvestment( ) );
|
||||
assertEquals( TEST_MIL_INVESTMENT , record.getMilInvestment( ) );
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue