@Test(expectedExceptions = IllegalArgumentException.class) public void testMustBeBlockDeviceMapping() { HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();; binder.bindToRequest(request, new File("foo")); }
@Test(expectedExceptions = NullPointerException.class) public void testNullIsBad() { HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build(); binder.bindToRequest(request, null); } }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMustBeBlockDeviceMapping() { HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build(); binder.bindToRequest(request, new File("foo")); }
@Test(expectedExceptions = NullPointerException.class) public void testNullIsBad() { HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build(); binder.bindToRequest(request, null); } }
public void testMappingOrdersLexicographically() { Map<String, BlockDevice> mapping = Maps.newLinkedHashMap(); mapping.put("apple", new BlockDevice("appleId", true)); Date date = new Date(999999l); mapping.put("cranberry", new BlockDevice("cranberry", Status.ATTACHED, date, false)); HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost") .addFormParam("InstanceId", "i-foo").build(); request = binder.bindToRequest(request, mapping); assertEquals( request.getPayload().getRawContent(), "Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=apple&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=appleId&BlockDeviceMapping.2.DeviceName=cranberry&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.Ebs.VolumeId=cranberry&InstanceId=i-foo"); }
public void testMappingOrdersLexicographically() { Map<String, BlockDevice> mapping = Maps.newLinkedHashMap(); mapping.put("apple", new BlockDevice("appleId", true)); Date date = new Date(999999L); mapping.put("cranberry", new BlockDevice("cranberry", Status.ATTACHED, date, false)); HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost") .addFormParam("InstanceId", "i-foo").build(); request = binder.bindToRequest(request, mapping); assertEquals( request.getPayload().getRawContent(), "Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=apple&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=appleId&BlockDeviceMapping.2.DeviceName=cranberry&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.Ebs.VolumeId=cranberry&InstanceId=i-foo"); }