google / data-transfer-project

The Data Transfer Project makes it easy for people to transfer their data between online service providers. We are establishing a common framework, including data models and protocols, to enable direct transfer of data both into and out of participating online service providers.

Home Page:http://datatransferproject.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: MediaContainerResource has no unit tests and has broken transmogrify path

jzacsh opened this issue · comments

background context: in the process of doing other work on the media vertical I needed to add unit tests for my own new code in MediaContainerResource

In doing that, I found that MediaContainerResource itself didn't have any tests, so nowhere to add test coverage for my new code. However since it was was forked from PhotoContainerResource porting the tests should be trivial (at least to get baseline coverage for majority of the forked logic), so I'm doing that as part of this bug to get the ball rolling here and unblock myself.

Tasks I'm tackling as part of this issue:

  • obvz, backfill the unit test of MediaContainerResource; original unit test is PhotosContainerResourceTest
  • fix new bug test backfilling discovered: we had a hidden runtime exception1: we were trying to rewrite
  • other less urgent things but takes 2sec to cleanup while I'm passing through
    • ensureCleanAlbumNames should be private
    • ensureRootAlbum doc is wrong and in fixing that might as well simplify that func (let the func do one thing; eg: not worry about boolean parameters)
    • [ ] [skipping this] #1060

Footnotes

  1. ("hidden" in that nothing was catching it, but it was there just waiting to be executed and thrown) runtime exception due to rewriting final ... album field pasted below for reference; compare to the original implementation that was forked, here:

    verifyTransmogrifyAlbums_NoRootPhotos
    java.lang.UnsupportedOperationException
        at com.google.common.collect.ImmutableCollection.add(ImmutableCollection.java:228)
        at org.datatransferproject.types.common.models.media.MediaContainerResource.ensureRootAlbum(MediaContainerResource.java:132)
        at org.datatransferproject.types.common.models.media.MediaContainerResource.transmogrify(MediaContainerResource.java:72)
        at org.datatransferproject.types.common.models.media.MediaContainerResourceTest.verifyTransmogrifyAlbums_NoRootPhotos(MediaContainerResourceTest.java:108)
    

(decided to punt the last detail to #1060)