@@ -0,0 +1,2266 @@
+// Copyright (C) 2015 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.gerrit.server.events;%0A%0Aimport static com.google.common.truth.Truth.assertThat;%0Aimport static org.junit.Assert.fail;%0A%0Aimport com.google.gerrit.server.events.Event;%0Aimport com.google.gerrit.server.events.EventTypes;%0A%0Aimport org.junit.Test;%0A%0Apublic class EventTypesTest %7B%0A  public static class TestEvent extends Event %7B%0A    public TestEvent() %7B%0A      super(%22test-event%22);%0A    %7D%0A  %7D%0A%0A  public static class TestEvent2 extends Event %7B%0A    public TestEvent2() %7B%0A      super(%22test-event%22); // Intentionally same as in TestEvent%0A    %7D%0A  %7D%0A%0A  public static class AnotherTestEvent extends Event %7B%0A    public AnotherTestEvent() %7B%0A      super(%22another-test-event%22);%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void testEventTypeRegistration() %7B%0A    EventTypes.registerClass(new TestEvent());%0A    EventTypes.registerClass(new AnotherTestEvent());%0A    assertThat(EventTypes.getClass(%22test-event%22)).isEqualTo(TestEvent.class);%0A    assertThat(EventTypes.getClass(%22another-test-event%22))%0A      .isEqualTo(AnotherTestEvent.class);%0A%0A    try %7B%0A      EventTypes.registerClass(new TestEvent());%0A      fail(%22Expected IllegalArgumentException%22);%0A    %7D catch (IllegalArgumentException e) %7B%0A      assertThat(EventTypes.getClass(%22test-event%22)).isEqualTo(TestEvent.class);%0A    %7D%0A%0A    try %7B%0A      EventTypes.registerClass(new TestEvent2());%0A      fail(%22Expected IllegalArgumentException%22);%0A    %7D catch (IllegalArgumentException e) %7B%0A      assertThat(EventTypes.getClass(%22test-event%22)).isEqualTo(TestEvent.class);%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void testGetClassForNonExistingType() %7B%0A    Class%3C?%3E clazz = EventTypes.getClass(%22does-not-exist-event%22);%0A    assertThat(clazz).isNull();%0A  %7D%0A%7D%0A

Add tests for registration of events with EventTypes