@Test
  public void shouldAuthorizeParameterDeletionAndSaveEvent() {
    // given
    SimpleParameter parameter = new SimpleParameter().withName("test").withInputLevels(1);
    paramManager.createParameter(USER, REPOSITORY_NAME, parameter);

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

    // then
    assertThat(inMemoryEventLogRepository.findFirstEvent(Action.DELETE_PARAMETER)).isNotNull();
    assertThat(inMemoryParamRepository.inspector().hasParameter("test")).isFalse();
  }
  @Test
  public void shouldAuthorizeEntryAdditionAndSaveEvent() {
    // given
    paramManager.createParameter(
        USER, REPOSITORY_NAME, new SimpleParameter().withName("test").withInputLevels(1));
    ParameterEntry entry = new SimpleParameterEntry("value");

    // when
    paramManager.addEntries(USER, REPOSITORY_NAME, "test", Arrays.asList(entry));

    // then
    assertThat(inMemoryEventLogRepository.findFirstEvent(Action.ADD_ENTRY)).isNotNull();
    assertThat(inMemoryParamRepository.load("test")).hasEntries(1);
  }
  @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 shouldAuthorizeParameterUpdateAndSaveEvent() {
    // given
    SimpleParameter parameter = new SimpleParameter().withName("test").withInputLevels(1);
    paramManager.createParameter(USER, REPOSITORY_NAME, parameter);

    SimpleParameter parameterUpdate = new SimpleParameter().withInputLevels(2);

    // when
    paramManager.updateParameter(USER, REPOSITORY_NAME, "test", parameterUpdate);

    // then
    assertThat(inMemoryEventLogRepository.findFirstEvent(Action.UPDATE_PARAMETER)).isNotNull();
    assertThat(inMemoryParamRepository.load("test")).hasInputLevels(2);
  }
  @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");
  }
  @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");
  }