Buggy code:
public class OpenStackNetworkImplTest { OpenstackNetworkClientImpl openStackNetworkImpl = new OpenstackNetworkClientImpl ( ) ; ClaudiaData claudiaData ; private OpenStackUtil openStackUtil ; private String REGION = "region" ; private String NETWORK_STRING = "{network:<seq2seq4repair_space>{\"status\":<seq2seq4repair_space>\"ACTIVE\",<seq2seq4repair_space>\"subnets\":<seq2seq4repair_space>" + ( ( ( ( ( "[\"2b7a07f6-0b73-46a1-9327-6911c0480f49\"],<seq2seq4repair_space>\"name\":<seq2seq4repair_space>" + "<seq2seq4repair_space>\"network\",<seq2seq4repair_space>\"provider:physical_network\":<seq2seq4repair_space>null,<seq2seq4repair_space>\"admin_state_up\":<seq2seq4repair_space>true,<seq2seq4repair_space>" ) + "\"tenant_id\":<seq2seq4repair_space>\"67c979f51c5b4e89b85c1f876bdffe31\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:network_type\":<seq2seq4repair_space>\"gre\",<seq2seq4repair_space>\"router:external\":<seq2seq4repair_space>false,<seq2seq4repair_space>\"shared\":<seq2seq4repair_space>false,<seq2seq4repair_space>" ) + "\"id\":<seq2seq4repair_space>\"044aecbe-3975-4318-aad2-a1232dcde47d\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:segmentation_id\":<seq2seq4repair_space>8}}" ) ; private String NETWORKS_STRING_1NET = "{networks:<seq2seq4repair_space>{\"status\":<seq2seq4repair_space>\"ACTIVE\",<seq2seq4repair_space>\"subnets\":<seq2seq4repair_space>" + ( ( ( ( ( "[\"2b7a07f6-0b73-46a1-9327-6911c0480f49\"],<seq2seq4repair_space>\"name\":<seq2seq4repair_space>" + "<seq2seq4repair_space>\"network\",<seq2seq4repair_space>\"provider:physical_network\":<seq2seq4repair_space>null,<seq2seq4repair_space>\"admin_state_up\":<seq2seq4repair_space>true,<seq2seq4repair_space>" ) + "\"tenant_id\":<seq2seq4repair_space>\"67c979f51c5b4e89b85c1f876bdffe31\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:network_type\":<seq2seq4repair_space>\"gre\",<seq2seq4repair_space>\"router:external\":<seq2seq4repair_space>false,<seq2seq4repair_space>\"shared\":<seq2seq4repair_space>false,<seq2seq4repair_space>" ) + "\"id\":<seq2seq4repair_space>\"044aecbe-3975-4318-aad2-a1232dcde47d\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:segmentation_id\":<seq2seq4repair_space>8}}" ) ; private String NETWORKS_STRING = "{\"networks\":<seq2seq4repair_space>[{\"status\":<seq2seq4repair_space>\"ACTIVE\",<seq2seq4repair_space>\"subnets\":<seq2seq4repair_space>" + ( ( ( ( ( ( ( ( ( ( ( "[\"2b7a07f6-0b73-46a1-9327-6911c0480f49\"],<seq2seq4repair_space>\"name\":<seq2seq4repair_space>" + "<seq2seq4repair_space>\"dia146\",<seq2seq4repair_space>\"provider:physical_network\":<seq2seq4repair_space>null,<seq2seq4repair_space>\"admin_state_up\":" ) + "<seq2seq4repair_space>true,<seq2seq4repair_space>\"tenant_id\":<seq2seq4repair_space>\"67c979f51c5b4e89b85c1f876bdffe31\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:network_type\":<seq2seq4repair_space>\"gre\",<seq2seq4repair_space>\"router:external\":<seq2seq4repair_space>false,<seq2seq4repair_space>\"shared\":" ) + "<seq2seq4repair_space>false,<seq2seq4repair_space>\"id\":<seq2seq4repair_space>\"044aecbe-3975-4318-aad2-a1232dcde47d\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:segmentation_id\":<seq2seq4repair_space>8},<seq2seq4repair_space>{\"status\":<seq2seq4repair_space>\"ACTIVE\",<seq2seq4repair_space>\"subnets\":<seq2seq4repair_space>" ) + "[\"e2d10e6b-33c3-400c-88d6-f905d4cd02f2\"],<seq2seq4repair_space>\"name\":<seq2seq4repair_space>\"ext-net\"," ) + "<seq2seq4repair_space>\"provider:physical_network\":<seq2seq4repair_space>null,<seq2seq4repair_space>\"admin_state_up\":<seq2seq4repair_space>true,<seq2seq4repair_space>\"tenant_id\":" ) + "<seq2seq4repair_space>\"08bed031f6c54c9d9b35b42aa06b51c0\",<seq2seq4repair_space>\"provider:network_type\":<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"gre\",<seq2seq4repair_space>\"router:external\":<seq2seq4repair_space>true,<seq2seq4repair_space>\"shared\":<seq2seq4repair_space>false,<seq2seq4repair_space>\"id\":<seq2seq4repair_space>" ) + "\"080b5f2a-668f-45e0-be23-361c3a7d11d0\",<seq2seq4repair_space>\"provider:segmentation_id\":<seq2seq4repair_space>1}" ) + "]}" ) ; @ Before public void setUp ( ) { } @ Test public void shouldListNetworks ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldListPortsFromNetwork ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldLoadNotSharedNetworks ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldObtainDataNetwork ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldAddNetworkToPublicRouter ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldDeployDefaultNetwork ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldDeployNetwork ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldDestroyNetwork ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldDestroyRouter ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldDeleteNetworkToPublicRouter ( ) throws InfrastructureException , OpenStackException { } @ Test public void shouldLoadNetworkNoId ( ) throws EntityNotFoundException , InfrastructureException , OpenStackException { String response2 = "{\"status\":<seq2seq4repair_space>\"ACTIVE\",<seq2seq4repair_space>\"subnets\":<seq2seq4repair_space>" + ( ( ( ( ( "[\"2b7a07f6-0b73-46a1-9327-6911c0480f49\"],<seq2seq4repair_space>\"name\":<seq2seq4repair_space>" + "<seq2seq4repair_space>\"MYNET\",<seq2seq4repair_space>\"provider:physical_network\":<seq2seq4repair_space>null,<seq2seq4repair_space>\"admin_state_up\":<seq2seq4repair_space>" ) + "true,<seq2seq4repair_space>\"tenant_id\":<seq2seq4repair_space>\"67c979f51c5b4e89b85c1f876bdffe31\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:network_type\":<seq2seq4repair_space>\"gre\",<seq2seq4repair_space>\"router:external\":<seq2seq4repair_space>false,<seq2seq4repair_space>" ) + "\"shared\":<seq2seq4repair_space>true,<seq2seq4repair_space>\"id\":<seq2seq4repair_space>\"044aecbe-3975-4318-aad2-a1232dcde47d\",<seq2seq4repair_space>" ) + "<seq2seq4repair_space>\"provider:segmentation_id\":<seq2seq4repair_space>8}}" ) ; String response3 = "\n" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "\n" + "<seq2seq4repair_space>{\n" ) + "<seq2seq4repair_space>\"subnet\":\n" ) + "<seq2seq4repair_space>{\n" ) + "<seq2seq4repair_space>\"name\":<seq2seq4repair_space>\"dd\",\n" ) + "<seq2seq4repair_space>\"enable_dhcp\":<seq2seq4repair_space>true,\n" ) + "<seq2seq4repair_space>\"network_id\":<seq2seq4repair_space>\"33cb6d12-3792-4ff7-8abe-8f948ce60a4d\",\n" ) + "<seq2seq4repair_space>\"tenant_id\":<seq2seq4repair_space>\"00000000000000000000000000000046\",\n" ) + "<seq2seq4repair_space>\"dns_nameservers\":\n" ) + "<seq2seq4repair_space>[\n" ) + "<seq2seq4repair_space>],\n" ) + "<seq2seq4repair_space>\"allocation_pools\":\n" ) + "<seq2seq4repair_space>[\n" ) + "<seq2seq4repair_space>{\n" ) + "<seq2seq4repair_space>\"start\":<seq2seq4repair_space>\"12.1.0.2\",\n" ) + "<seq2seq4repair_space>\"end\":<seq2seq4repair_space>\"12.1.0.254\"\n" ) + "<seq2seq4repair_space>}\n" ) + "<seq2seq4repair_space>],\n" ) + "<seq2seq4repair_space>\"host_routes\":\n" ) + "<seq2seq4repair_space>[\n" ) + "<seq2seq4repair_space>],\n" ) + "<seq2seq4repair_space>\"ip_version\":<seq2seq4repair_space>4,\n" ) + "<seq2seq4repair_space>\"gateway_ip\":<seq2seq4repair_space>\"12.1.0.1\",\n" ) + "<seq2seq4repair_space>\"cidr\":<seq2seq4repair_space>\"12.1.0.0//24\",\n" ) + "<seq2seq4repair_space>\"id\":<seq2seq4repair_space>\"6959446a-204b-4e68-a5d2-f7a3ef5a442a\"\n" ) + "<seq2seq4repair_space>}\n" ) + "<seq2seq4repair_space>}\n" ) + "\n" ) ; <START_BUG> NetworkInstance net = new NetworkInstance ( "dia146" , "vdc" , "region" ) ; <END_BUG> when ( openStackUtil . listNetworks ( any ( PaasManagerUser . class ) , anyString ( ) ) ) . thenReturn ( NETWORKS_STRING ) ; when ( openStackUtil . getNetworkDetails ( anyString ( ) , anyString ( ) , anyString ( ) , anyString ( ) ) ) . thenReturn ( response2 ) ; when ( openStackUtil . getSubNetworkDetails ( anyString ( ) , anyString ( ) , anyString ( ) , anyString ( ) ) ) . thenReturn ( response3 ) ; openStackNetworkImpl . loadNetwork ( claudiaData , net , REGION ) ; assertNotNull ( net . getIdNetwork ( ) ) ; } @ Test public void shouldLoadNetworkNoIdNetNotExists ( ) throws InfrastructureException , OpenStackException , JSONException { } }

Fix:
NetworkInstance net = new NetworkInstance ( "ext-net" , "\"08bed031f6c54c9d9b35b42aa06b51c0\"" , "region" ) ;