public void testConvertServerDrive() { CloudSigma2Api api = EasyMock.createMock(CloudSigma2Api.class); DriveInfo mockDrive = new DriveInfo.Builder() .uuid(input.getDrive().getUuid()) .size(new BigInteger("1024000000")) .build(); expect(api.getDriveInfo(input.getDrive().getUuid())).andReturn(mockDrive); replay(api); ServerDriveToVolume function = new ServerDriveToVolume(api); assertEquals(function.apply(input), expected); verify(api); } }
@Test public void testCreateDrives() throws Exception { List<DriveInfo> newDrives = ImmutableList.of( new DriveInfo.Builder() .name("New Drive") .size(new BigInteger("2073741824")) .media(MediaType.DISK) .build(), new DriveInfo.Builder() .name("Test Drive") .size(new BigInteger("6073741824")) .media(MediaType.DISK) .build()); createdDrives = api.createDrives(newDrives); assertEquals(newDrives.size(), createdDrives.size()); for (int i = 0; i < newDrives.size(); i++) { checkDrive(newDrives.get(i), createdDrives.get(i)); } }
.tags(ImmutableList.of("tag_uuid_1", "tag_uuid_2")) .uuid("e96f3c63-6f50-47eb-9401-a56c5ccf6b32") .build();
.size(new BigInteger("1024000000")) .allowMultimount(false) .build(), new DriveInfo.Builder() .media(org.jclouds.cloudsigma2.domain.MediaType.DISK) .size(new BigInteger("1024000000")) .allowMultimount(false) .build(), new DriveInfo.Builder() .media(org.jclouds.cloudsigma2.domain.MediaType.DISK) .size(new BigInteger("1024000000")) .allowMultimount(false) .build())); assertNotNull(result); assertEquals(result.size(), 3);
.uuid(drive.getDriveUuid()) .size(new BigInteger("1024000")) .build();
@Test public void testCloneDrive() throws Exception { String uuid = "92ca1450-417e-4cc1-983b-1015777e2591"; CloudSigma2Api api = requestSendsResponse( postBuilder() .payload(payloadFromResourceWithContentType("/drives-create-request.json", MediaType.APPLICATION_JSON)) .endpoint(endpoint + "drives/" + uuid + "/action/?do=clone") .build(), responseBuilder() .payload(payloadFromResourceWithContentType("/drive-cloned.json", MediaType.APPLICATION_JSON)) .build()); DriveInfo result = api.cloneDrive(uuid, new DriveInfo.Builder() .media(org.jclouds.cloudsigma2.domain.MediaType.DISK) .name("test_drive_0") .size(new BigInteger("1024000000")) .allowMultimount(false) .build()); assertNotNull(result); }
@Test public void testEditDrive() throws Exception { String uuid = "e96f3c63-6f50-47eb-9401-a56c5ccf6b32"; CloudSigma2Api api = requestSendsResponse( putBuilder() .payload(payloadFromResourceWithContentType("/drives-create-request.json", MediaType.APPLICATION_JSON)) .endpoint(endpoint + "drives/" + uuid + "/") .build(), responseBuilder() .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON)) .build()); DriveInfo result = api.editDrive(uuid, new DriveInfo.Builder() .media(org.jclouds.cloudsigma2.domain.MediaType.DISK) .name("test_drive_0") .size(new BigInteger("1024000000")) .allowMultimount(false) .build()); assertNotNull(result); }
@Test public void testCreateDrive() throws Exception { CloudSigma2Api api = requestSendsResponse( postBuilder() .payload(payloadFromResourceWithContentType("/drives-create-request.json", MediaType.APPLICATION_JSON)) .endpoint(endpoint + "drives/") .build(), responseBuilder() .payload(payloadFromResourceWithContentType("/drives-single.json", MediaType.APPLICATION_JSON)) .build()); DriveInfo result = api.createDrive(new DriveInfo.Builder() .media(org.jclouds.cloudsigma2.domain.MediaType.DISK) .name("test_drive_0") .size(new BigInteger("1024000000")) .allowMultimount(false) .build()); assertNotNull(result); }
private static DriveInfo mockDrive(DriveStatus status) { return new DriveInfo.Builder().uuid(status.name()).status(status).build(); } }
@Test public void testCreateDrive() throws Exception { DriveInfo newDrive = new DriveInfo.Builder() .name("test drive") .size(new BigInteger("2073741824")) .media(MediaType.DISK) .build(); createdDrive = api.createDrive(newDrive); checkDrive(newDrive, createdDrive); }
@Test(dependsOnMethods = {"testCreateDrive"}) public void testEditDrive() throws Exception { DriveInfo editedDrive = new DriveInfo.Builder() .name("Edited Drive") .size(createdDrive.getSize()) .media(MediaType.DISK) .build(); checkDrive(editedDrive, api.editDrive(createdDrive.getUuid(), editedDrive)); }