MobilityModule extends Module implements IMobilityModule, IMobilityModuleController { @Override public double costForMovingInLevel(final LevelType levelType) throws NotAuthenticatedException, NotObservableException { assertObservable(); return ifNotNullElse( movementCost.get( levelType ), Double.MAX_VALUE ); } protected  MobilityModule(final ImmutableResourceCost resourceCost, final int movementSpeed, final Map<LevelType, Double> movementCost,
                             final Map<LevelType, Double> levelingCost); @Override double getRemainingSpeed(); @Override double getMovementSpeed(); @Override double costForMovingInLevel(final LevelType levelType); @Override double costForLevelingToLevel(final LevelType levelType); @Override Leveling leveling(final LevelType levelType); @Override Movement movement(final ITile target); @Override IMobilityModuleController getController(); @Override IMobilityModule getModule();  }
@Test public void testCostForMovingInLevel() throws Exception { MobilityModule module = MobilityModule.createWithStandardResourceCost() .movementSpeed( 0 ) .movementCost( ImmutableMap.of( LevelType.GROUND, 1d ) ) .levelingCost( ImmutableMap.<LevelType, Double>of() ); createUnit( testUnitType( "Ground Mover", module ) ); assertEquals( 1d, module.costForMovingInLevel( LevelType.GROUND ) ); assertEquals( Double.MAX_VALUE, module.costForMovingInLevel( LevelType.SKY ) ); assertEquals( Double.MAX_VALUE, module.costForMovingInLevel( LevelType.SPACE ) ); module.getGameObject().getController().die(); ImmutableMap.Builder<LevelType, Double> builder = ImmutableMap.builder(); for (final LevelType levelType : LevelType.values()) builder.put( levelType, (double) levelType.ordinal() ); module = MobilityModule.createWithStandardResourceCost() .movementSpeed( 0 ) .movementCost( builder.build() ) .levelingCost( ImmutableMap.<LevelType, Double>of() ); createUnit( testUnitType( "Everywhere Mover", module ) ); for (final LevelType levelType : LevelType.values()) assertEquals( (double) levelType.ordinal(), module.costForMovingInLevel( levelType ) ); }