@Test
public void testSetUnsetFavoriteDataSet() throws IOException {

    String dsId1 = UUID.randomUUID().toString();
    String dsId2 = UUID.randomUUID().toString();
    when().get("/datasets/favorites").then().statusCode(OK.value()).body(equalTo("[]"));
    dataSetMetadataRepository.save(metadataBuilder.metadata().id(dsId1).build());
    dataSetMetadataRepository.save(metadataBuilder.metadata().id(dsId2).build());
    // check set
    when().put("/datasets/{id}/favorite", dsId1).then().statusCode(OK.value());
    when().put("/datasets/{id}/favorite?unset=false", dsId2).then().statusCode(OK.value());
    List<String> favoritesResp = from(when().get("/datasets/favorites").asString()).get(); //$NON-NLS-1$
    assertEquals(2, favoritesResp.size());
    assertThat(favoritesResp, hasItems(dsId1, dsId2));
    // check unset
    when().put("/datasets/{id}/favorite?unset=true", dsId2).then().statusCode(OK.value());
    favoritesResp = from(when().get("/datasets/favorites").asString()).get();
    assertEquals(1, favoritesResp.size());
    assertThat(favoritesResp, hasItem(dsId1));
    // check wrong datasetId
    String wrongDsId = UUID.randomUUID().toString();
    assertThat(dataSetMetadataRepository.get(wrongDsId), nullValue());
    given()
            .contentType(JSON) //
            .body(IOUtils.toString(this.getClass().getResourceAsStream(METADATA_JSON), UTF_8)) //
            .when() //
            .put("/datasets/{id}/favorite", wrongDsId) //
            .then() //
            .statusCode(HttpStatus.NOT_FOUND.value());
}