<BUG>when(eventRepository.findByType(Arrays.asList(EventType.PUBLISH_API, EventType.UNPUBLISH_API, EventType.START_API, EventType.STOP_API))).thenReturn(Collections.singleton(mockEvent));when(apiRepository.findAll()).thenReturn(Collections.singleton(api));</BUG><CONTEXT>public void test_twiceWithSameApi() throws Exception {io.gravitee.repository.management.model.Api api =new RepositoryApiBuilder().id("api-test").updatedAt(new Date()).definition("test").build();final Api mockApi = mockApi(api);final Event mockEvent = mockEvent(api, EventType.PUBLISH_API);<extra_id_0>when(apiManager.get(api.getId())).thenReturn(null);syncManager.refresh();when(apiManager.get(api.getId())).thenReturn(mockApi);</CONTEXT>
when(eventRepository.search(new EventCriteria.Builder().types(EventType.PUBLISH_API, EventType.UNPUBLISH_API, EventType.START_API, EventType.STOP_API).build())).thenReturn(Collections.singletonList(mockEvent));when(apiRepository.findAll()).thenReturn(Collections.singleton(api));