@Test
public void should_not_increment_asset_order_in_component_when_asset_is_the_last() throws Exception {

    Asset[] assets = getSortedAssets();
    Page page = aPage().withId("page-id").withName("my-page").withAsset(assets).build();
    when(repository.get("page-id")).thenReturn(page);
    assets[2].setComponentId("page-id");
    Asset assetReturned = assetService.changeAssetOrderInComponent(page, "asset3", INCREMENT);
    assertThat(assetReturned.getName()).isEqualTo("asset3");
    assertThat(assets[0].getOrder()).isEqualTo(1);
    assertThat(assets[1].getOrder()).isEqualTo(2);
    assertThat(assets[2].getOrder()).isEqualTo(3);
    verify(repository).updateLastUpdateAndSave(page);
}