@Test public void add_and_get_developer_id() { DbIdsRepositoryImpl cache = new DbIdsRepositoryImpl(); cache.setDeveloperId(SOME_DEVELOPER, 100L); assertThat(cache.getDeveloperId(SOME_DEVELOPER)).isEqualTo(100L); }
@Test public void add_and_get_component_id() { DbIdsRepositoryImpl cache = new DbIdsRepositoryImpl(); cache.setComponentId(SOME_COMPONENT, 10L); assertThat(cache.getComponentId(SOME_COMPONENT)).isEqualTo(10L); }
@Test public void fail_if_developer_id_already_set() { DbIdsRepositoryImpl cache = new DbIdsRepositoryImpl(); cache.setDeveloperId(SOME_DEVELOPER, 10L); thrown.expect(IllegalStateException.class); thrown.expectMessage( "Id '10' is already registered in repository for Developer '" + SOME_DEVELOPER + "', can not set new id '11'"); cache.setDeveloperId(SOME_DEVELOPER, 11L); }
@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); }