@Test
  public void shouldAuthorizeLevelOrderingAndSaveEvent() {
    // given
    paramManager.createParameter(
        USER, REPOSITORY_NAME, new SimpleParameter().withName("test").withInputLevels(1));
    LevelKey levelKey2 =
        paramManager
            .addLevel(USER, REPOSITORY_NAME, "test", new SimpleLevel().withName("test-level2"))
            .levelKey();
    LevelKey levelKey1 =
        paramManager
            .addLevel(USER, REPOSITORY_NAME, "test", new SimpleLevel().withName("test-level1"))
            .levelKey();

    List<LevelKey> newOrder = Arrays.asList(levelKey1, levelKey2);

    // when
    paramManager.reorderLevels(USER, REPOSITORY_NAME, "test", newOrder);

    // then
    assertThat(inMemoryEventLogRepository.findFirstEvent(Action.REOREDER_LEVELS)).isNotNull();
    assertThat(inMemoryParamRepository.load("test"))
        .namedLevelsInOrder("test-level1", "test-level2");
  }
  @Test
  public void shouldAuthorizeLevelAdditionAndSaveEvent() {
    // given
    SimpleParameter parameter = new SimpleParameter().withName("test").withInputLevels(1);
    paramManager.createParameter(USER, REPOSITORY_NAME, parameter);

    SimpleLevel level = new SimpleLevel().withName("test-level");

    // when
    paramManager.addLevel(USER, REPOSITORY_NAME, "test", level);

    // then
    assertThat(inMemoryEventLogRepository.findFirstEvent(Action.ADD_LEVEL)).isNotNull();
    assertThat(inMemoryParamRepository.load("test")).firstLevel().hasName("test-level");
  }
  @Test
  public void shouldAuthorizeLevelDeletionAndSaveEvent() {
    // given
    paramManager.createParameter(
        USER, REPOSITORY_NAME, new SimpleParameter().withName("test").withInputLevels(1));
    LevelKey levelKey =
        paramManager
            .addLevel(USER, REPOSITORY_NAME, "test", new SimpleLevel().withName("test-level1"))
            .levelKey();

    // when
    paramManager.deleteLevel(USER, REPOSITORY_NAME, "test", levelKey);

    // then
    assertThat(inMemoryEventLogRepository.findFirstEvent(Action.DELETE_LEVEL)).isNotNull();
    assertThat(inMemoryParamRepository.load("test")).hasNoLevels();
  }
  @Test
  public void shouldAuthorizeLevelUpdateAndSaveEvent() {
    // given
    paramManager.createParameter(
        USER, REPOSITORY_NAME, new SimpleParameter().withName("test").withInputLevels(1));
    LevelKey levelKey =
        paramManager
            .addLevel(USER, REPOSITORY_NAME, "test", new SimpleLevel().withName("test-level"))
            .levelKey();

    SimpleLevel levelUpdate = new SimpleLevel().withName("test-level").withMatcher("matcher");

    // when
    paramManager.updateLevel(USER, REPOSITORY_NAME, "test", levelKey, levelUpdate);

    // then
    assertThat(inMemoryEventLogRepository.findFirstEvent(Action.UPDATE_LEVEL)).isNotNull();
    assertThat(inMemoryParamRepository.load("test")).firstLevel().hasMatcher("matcher");
  }