diff --git a/extensions/data-transfer/portability-data-transfer-google/src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java b/extensions/data-transfer/portability-data-transfer-google/src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java index ad6599888..d0702b558 100644 --- a/extensions/data-transfer/portability-data-transfer-google/src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java +++ b/extensions/data-transfer/portability-data-transfer-google/src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java @@ -307,7 +307,7 @@ private HttpResponse handleHttpResponseException( } } - String generateParamsString(Optional> params) { + private String generateParamsString(Optional> params) { Map updatedParams = new ArrayMap<>(); if (params.isPresent()) { updatedParams.putAll(params.get()); diff --git a/extensions/data-transfer/portability-data-transfer-google/src/test/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterfaceTest.java b/extensions/data-transfer/portability-data-transfer-google/src/test/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterfaceTest.java index 0039c73f9..1e9113cd7 100644 --- a/extensions/data-transfer/portability-data-transfer-google/src/test/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterfaceTest.java +++ b/extensions/data-transfer/portability-data-transfer-google/src/test/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterfaceTest.java @@ -32,11 +32,14 @@ import com.google.api.client.http.json.JsonHttpContent; import com.google.api.client.json.JsonFactory; import com.google.common.collect.ImmutableMap; +import com.google.photos.types.proto.MediaItem; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import org.datatransferproject.api.launcher.Monitor; @@ -46,6 +49,7 @@ import org.datatransferproject.datatransfer.google.mediaModels.GoogleAlbum; import org.datatransferproject.datatransfer.google.mediaModels.GoogleMediaItem; import org.datatransferproject.datatransfer.google.mediaModels.MediaItemSearchResponse; +import org.datatransferproject.datatransfer.google.mediaModels.NewMediaItem; import org.datatransferproject.datatransfer.google.mediaModels.NewMediaItemResult; import org.datatransferproject.datatransfer.google.mediaModels.NewMediaItemUpload; import org.datatransferproject.spi.transfer.types.InvalidTokenException; @@ -272,29 +276,30 @@ void uploadEmptyMediaContent() void createPhotos() throws Exception { BatchMediaItemResponse batchMediaItemResponse = new BatchMediaItemResponse( new NewMediaItemResult[]{}); + List newMediaItem = new ArrayList<>(); + NewMediaItemUpload newMediaItemUpload = new NewMediaItemUpload(ALBUM_ID,newMediaItem); TypeReference> typeRef = new TypeReference>() { }; - Map albumMap = objectMapper.readValue( - objectMapper.writeValueAsString(batchMediaItemResponse), typeRef); - Map params = ImmutableMap.of("album", albumMap); + Map params = objectMapper.readValue( + objectMapper.writeValueAsString(newMediaItemUpload), typeRef); GooglePhotosInterface photosInterfaceSpy = Mockito.spy(this.googlePhotosInterface); Mockito.doReturn(batchMediaItemResponse).when(photosInterfaceSpy) .makePostRequest(anyString(), any(), any(), any(), any()); - BatchMediaItemResponse apiResponse = googlePhotosInterface.createPhotos( - any(NewMediaItemUpload.class)); + BatchMediaItemResponse apiResponse = photosInterfaceSpy.createPhotos( + newMediaItemUpload); ArgumentCaptor urlStringCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor contentCaptor = ArgumentCaptor.forClass(JsonHttpContent.class); Mockito.verify(photosInterfaceSpy) .makePostRequest(urlStringCaptor.capture(), any(), any(), contentCaptor.capture(), any()); assertEquals(batchMediaItemResponse, apiResponse); - assertEquals(BASE_URL + "albums", urlStringCaptor.getValue()); + assertEquals(BASE_URL + "mediaItems:batchCreate", urlStringCaptor.getValue()); assertEquals(params, contentCaptor.getValue().getData()); } - @Test +// @Test void makePostRequest() { // Discussion: I Believe this method should be kept private for the interface to make sense }