@Test
public void testGetOrCreateReleaseFoundByExternalIDs() {

    SW360SparseRelease sparseRelease = new SW360SparseRelease();
    SW360Release foundRelease = new SW360Release();
    SW360Release queryRelease = new SW360Release();
    SW360Release patchedRelease = new SW360Release();
    Map<String, String> extIDs = Collections.singletonMap("foo", "bar");
    final String copyright = "(C) Test copyright";
    queryRelease.setExternalIds(extIDs);
    foundRelease.setCopyrights(copyright);
    when(releaseClientAdapter.getSparseReleaseByExternalIds(extIDs)).thenReturn(Optional.of(sparseRelease));
    when(releaseClientAdapter.enrichSparseRelease(sparseRelease)).thenReturn(Optional.of(foundRelease));
    when(releaseClientAdapter.updateRelease(any()))
            .thenAnswer((Answer<SW360Release>) invocationOnMock -> {
                SW360Release rel = invocationOnMock.getArgument(0);
                assertThat(rel.getExternalIds()).isEqualTo(extIDs);
                assertThat(rel.getCopyrights()).isEqualTo(copyright);
                return patchedRelease;
            });
    assertThat(metaDataUpdater.getOrCreateRelease(queryRelease, true)).isEqualTo(patchedRelease);
}