Buggy code:
public class NetworkResourceStubImpl extends AbstractAPIStub implements NetworkResourceStub { public static VlanNetwork createFlexObject ( final VLANNetworkDto dto ) { } @ SuppressWarnings ( "unchecked" ) @ Override public DataResult < Boolean > checkVLANTagAvailability ( final Integer datacenterId , final Integer proposedVLANTag , final Integer currentVlanId ) { } @ Override public BasicResult createPrivateVlan ( final UserSession userSession , final Integer vdcId , final VLANNetworkDto dto ) { } @ Override public BasicResult createPublicVlan ( final Integer datacenterId , final String networkName , final Integer vlanTag , final NetworkConfiguration configuration , final Enterprise enterprise , final boolean unmanaged , final Set < DhcpOption > dhcpOptions ) { } @ Override public BasicResult deletePrivateVlan ( final Integer vdcId , final Integer vlanId ) { } @ Override public BasicResult deletePublicVlan ( final Integer datacenterId , final Integer vlanId ) { } @ Override public BasicResult editPrivateVlan ( final Integer vdcId , final Integer vlanId , final VLANNetworkDto vlandto ) { } @ Override public BasicResult editPublicIp ( final Integer datacenterId , final Integer vlanId , final Integer idManagement , final IpPoolManagement ipPoolManagement ) { } @ Override public BasicResult editPublicIps ( final Integer datacenterId , final Integer vlanNetworkId , final ArrayList < IpPoolManagement > listOfPublicIPs ) { } @ Override public BasicResult editPublicVlan ( final Integer datacenterId , final Integer vlanNetworkId , final String vlanName , final Integer vlanTag , final NetworkConfiguration configuration , final Boolean defaultNetwork , final Enterprise enterprise , final Set < DhcpOption > dhcpOptions ) { } @ Override public BasicResult getEnterpriseFromReservedVlanId ( final Integer datacenterId , final Integer vlanId ) { } @ Override public BasicResult getEnterprisesWithNetworksByDatacenter ( final UserSession userSession , final Integer datacenterId , final Integer offset , final Integer numElem , final String ipLike ) throws NetworkCommandException { DataResult < ListResponse < Enterprise > > dataResult = new DataResult < ListResponse < Enterprise > > ( ) ; List < Enterprise > listEnt = new ArrayList < Enterprise > ( ) ; StringBuilder buildRequest = new StringBuilder ( createDatacenterLink ( datacenterId ) ) ; buildRequest . append ( "//action//enterprises" ) ; buildRequest . append ( "?network=true" ) ; buildRequest . append ( ( "&startwith=" + offset ) ) ; buildRequest . append ( ( "&limit=" + numElem ) ) ; ClientResponse response = get ( buildRequest . toString ( ) ) ; if ( ( response . getStatusCode ( ) ) == 200 ) { EnterprisesDto enterprises = response . getEntity ( EnterprisesDto . class ) ; for ( EnterpriseDto entdto : enterprises . getCollection ( ) ) { Enterprise e = Enterprise . create ( entdto ) ; listEnt . add ( e ) ; } ListResponse < Enterprise > listResponse = new ListResponse < Enterprise > ( ) ; listResponse . setList ( listEnt ) ; <START_BUG> listResponse . setTotalNumEntities ( listEnt . size ( ) ) ; <END_BUG> dataResult . setData ( listResponse ) ; dataResult . setSuccess ( Boolean . TRUE ) ; } else { populateErrors ( response , dataResult , "getEnterprisesWithNetworksByDatacenter" ) ; } return dataResult ; } @ Override public BasicResult getExternalVlanAsDefaultInEnterpriseByDatacenterLimit ( final Integer id , final Integer datacenterId ) { } @ Override public BasicResult getExternalVlansByDatacenterInEnterprise ( final Integer datacenterId , final Integer enterpriseId ) { } @ Override public BasicResult getExternalVlansByVirtualDatacenter ( final VirtualDataCenter vdc ) { } @ Override public BasicResult getGatewayByVirtualMachine ( final Integer vdcId , final Integer vappId , final Integer vmId ) { } @ Override public BasicResult getGatewayListByVirtualMachine ( final Integer vdcId , final Integer vappId , final Integer vmId ) { } @ Override public BasicResult getInfoDHCPServer ( final UserSession userSession , final Integer vdcId ) throws NetworkCommandException { } @ Override public BasicResult getListNetworkPoolByEnterprise ( final Integer enterpriseId , final Integer offset , final Integer numElem , final String filterLike , final String orderBy , final Boolean asc ) throws NetworkCommandException { } @ Override public BasicResult getListNetworkPoolByPrivateVLAN ( final Integer vdcId , final Integer vlanId , final Integer offset , final Integer numberOfNodes , final String filterLike , final String orderBy , final Boolean asc , final Boolean onlyAvailable , final Boolean freeIps ) { } @ Override public BasicResult getListNetworkPoolByVirtualDatacenter ( final Integer vdcId , final Integer offset , final Integer numElem , final String filterLike , final String orderBy , final Boolean asc , String type ) throws NetworkCommandException { } @ Override public DataResult < ListResponse < IpPoolManagement > > getListNetworkPublicPoolByDatacenter ( final Integer datacenterId , final Integer offset , final Integer numberOfNodes , final String filterLike , final String orderBy , final Boolean asc , String type ) throws NetworkCommandException { } @ Override public BasicResult getListNetworkPublicPoolByVlan ( final Integer datacenterId , final Integer vlanId , final Integer offset , final Integer numberOfNodes , final String filterLike , final String orderBy , final Boolean asc , final Boolean all ) throws NetworkCommandException { } @ Override public BasicResult getListNetworkPublicPoolPurchasedByVirtualDatacenter ( final Integer vdcId , final Boolean onlyAvailable , final Integer offset , final Integer numberOfNodes , final String filterLike , final String orderBy , final Boolean asc ) throws NetworkCommandException { } @ Override public BasicResult getListNetworkPublicPoolToPurchaseByVirtualDatacenter ( final Integer vdcId , final Integer offset , final Integer numberOfNodes , final String filterLike , final String orderBy , final Boolean asc ) throws NetworkCommandException { } @ Override public BasicResult getNetworkPoolInfoByExternalVlan ( final VirtualDataCenter vdc , final Integer vlanId , final Integer offset , final Integer numberOfNodes , final String filterLike , final String orderBy , final Boolean asc , final Boolean available , final Boolean freeIps ) { } @ Override public BasicResult getNICsByVirtualMachine ( final Integer vdcId , final Integer vappId , final Integer vmId ) { } @ Override public BasicResult getPrivateNetworks ( final Integer vdcId ) { } @ Override public BasicResult getPublicNetwork ( final Integer datacenterId , final Integer vlanId ) { } @ Override public BasicResult getPublicVlansByDatacenter ( final Integer datacenterId , String type ) { }

Fix:
listResponse . setTotalNumEntities ( enterprises . getTotalSize ( ) ) ;