NeutronSubnetIpAllocationPool implements Serializable { public List<NeutronSubnetIpAllocationPool> splitPoolV6(String ipAddress) { List<NeutronSubnetIpAllocationPool> ans = new ArrayList<>(); BigInteger givenIp = NeutronSubnetIpAllocationPool.convertV6(ipAddress); BigInteger startIp = NeutronSubnetIpAllocationPool.convertV6(poolStart); BigInteger endIp = NeutronSubnetIpAllocationPool.convertV6(poolEnd); if (givenIp.compareTo(startIp) == 0 && givenIp.compareTo(endIp) < 0) { NeutronSubnetIpAllocationPool pool = new NeutronSubnetIpAllocationPool(); pool.setPoolStart(NeutronSubnetIpAllocationPool.bigIntegerToIp(startIp.add(BigInteger.ONE))); pool.setPoolEnd(poolEnd); ans.add(pool); return ans; } if (givenIp.compareTo(endIp) == 0 && givenIp.compareTo(startIp) > 0) { NeutronSubnetIpAllocationPool pool = new NeutronSubnetIpAllocationPool(); pool.setPoolStart(poolStart); pool.setPoolEnd(NeutronSubnetIpAllocationPool.bigIntegerToIp(endIp.subtract(BigInteger.ONE))); ans.add(pool); return ans; } if (givenIp.compareTo(endIp) < 0 && givenIp.compareTo(startIp) > 0) { NeutronSubnetIpAllocationPool pool = new NeutronSubnetIpAllocationPool(); pool.setPoolStart(poolStart); pool.setPoolEnd(NeutronSubnetIpAllocationPool.bigIntegerToIp(givenIp.subtract(BigInteger.ONE))); ans.add(pool); NeutronSubnetIpAllocationPool p2 = new NeutronSubnetIpAllocationPool(); p2.setPoolStart(NeutronSubnetIpAllocationPool.bigIntegerToIp(givenIp.add(BigInteger.ONE))); p2.setPoolEnd(poolEnd); ans.add(p2); return ans; } return null; } NeutronSubnetIpAllocationPool();  NeutronSubnetIpAllocationPool(String lowAddress, String highAddress); String getPoolStart(); void setPoolStart(String poolStart); String getPoolEnd(); void setPoolEnd(String poolEnd); boolean contains(String inputString); boolean containsV6(String inputString); static String join(String[] strings, String separator); List<NeutronSubnetIpAllocationPool> splitPool(String ipAddress); @Override String toString(); List<NeutronSubnetIpAllocationPool> splitPoolV6(String ipAddress);  }
@Test public void splitPoolV6Test() { NeutronSubnetIpAllocationPool apUT = new NeutronSubnetIpAllocationPool(); apUT.setPoolStart("2015:0:0:0:0:0:0:2"); apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); List<NeutronSubnetIpAllocationPool> result = apUT.splitPoolV6("2015:0:0:0:0:0:0:2"); Assert.assertEquals("splitPoolV6 Test 1.1: address == pool start (result size) failed", 1, result.size()); Assert.assertEquals("splitPoolV6 Test 1.2: address == pool start (pool start) failed", "2015:0:0:0:0:0:0:3", result.get(0).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 1.3: address == pool start (pool end) failed", "2015:0:0:0:0:0:0:6", result.get(0).getPoolEnd()); apUT = new NeutronSubnetIpAllocationPool(); apUT.setPoolStart("2015:0:0:0:0:0:0:2"); apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); result = apUT.splitPoolV6("2015:0:0:0:0:0:0:3"); Assert.assertEquals("splitPoolV6 Test 2.1: address one above pool start (result size) failed", 2, result.size()); Assert.assertEquals("splitPoolV6 Test 2.2: address one above pool start (pool 1 start) failed", "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 2.3: address one above pool start (pool 1 end) failed", "2015:0:0:0:0:0:0:2", result.get(0).getPoolEnd()); Assert.assertEquals("splitPoolV6 Test 2.4: address one above pool start (pool 2 start) failed", "2015:0:0:0:0:0:0:4", result.get(1).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 2.5: address one above pool start (pool 2 end) failed", "2015:0:0:0:0:0:0:6", result.get(1).getPoolEnd()); apUT = new NeutronSubnetIpAllocationPool(); apUT.setPoolStart("2015:0:0:0:0:0:0:2"); apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); result = apUT.splitPoolV6("2015:0:0:0:0:0:0:4"); Assert.assertEquals("splitPoolV6 Test 3.1: address one above pool start (result size) failed", 2, result.size()); Assert.assertEquals("splitPoolV6 Test 3.2: address one above pool start (pool 1 start) failed", "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 3.3: address one above pool start (pool 1 end) failed", "2015:0:0:0:0:0:0:3", result.get(0).getPoolEnd()); Assert.assertEquals("splitPoolV6 Test 3.4: address one above pool start (pool 2 start) failed", "2015:0:0:0:0:0:0:5", result.get(1).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 3.5: address one above pool start (pool 2 end) failed", "2015:0:0:0:0:0:0:6", result.get(1).getPoolEnd()); apUT = new NeutronSubnetIpAllocationPool(); apUT.setPoolStart("2015:0:0:0:0:0:0:2"); apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); result = apUT.splitPoolV6("2015:0:0:0:0:0:0:5"); Assert.assertEquals("splitPoolV6 Test 4.1: address one above pool start (result size) failed", 2, result.size()); Assert.assertEquals("splitPoolV6 Test 4.2: address one above pool start (pool 1 start) failed", "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 4.3: address one above pool start (pool 1 end) failed", "2015:0:0:0:0:0:0:4", result.get(0).getPoolEnd()); Assert.assertEquals("splitPoolV6 Test 4.4: address one above pool start (pool 2 start) failed", "2015:0:0:0:0:0:0:6", result.get(1).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 4.5: address one above pool start (pool 2 end) failed", "2015:0:0:0:0:0:0:6", result.get(1).getPoolEnd()); apUT = new NeutronSubnetIpAllocationPool(); apUT.setPoolStart("2015:0:0:0:0:0:0:2"); apUT.setPoolEnd("2015:0:0:0:0:0:0:6"); result = apUT.splitPoolV6("2015:0:0:0:0:0:0:6"); Assert.assertEquals("splitPoolV6 Test 5.1: address == pool start (result size) failed", 1, result.size()); Assert.assertEquals("splitPoolV6 Test 5.2: address == pool start (pool start) failed", "2015:0:0:0:0:0:0:2", result.get(0).getPoolStart()); Assert.assertEquals("splitPoolV6 Test 5.3: address == pool start (pool end) failed", "2015:0:0:0:0:0:0:5", result.get(0).getPoolEnd()); }