@Test public void fail_if_component_id_already_set() { DbIdsRepositoryImpl cache = new DbIdsRepositoryImpl(); cache.setComponentId(SOME_COMPONENT, 10L); thrown.expect(IllegalStateException.class); thrown.expectMessage( "Component id '10' is already registered in repository for Component '" + SOME_COMPONENT_KEY + "', can not set new id '11'"); cache.setComponentId(SOME_COMPONENT, 11L); }
@Test public void add_and_get_component_id() { DbIdsRepositoryImpl cache = new DbIdsRepositoryImpl(); cache.setComponentId(SOME_COMPONENT, 10L); assertThat(cache.getComponentId(SOME_COMPONENT)).isEqualTo(10L); }