use of io.gravitee.gateway.services.sync.builder.RepositoryApiBuilder in project gravitee-gateway by gravitee-io.
the class SyncManagerTest method test_deployApiWithTagInclusionExclusion.
@Test
public void test_deployApiWithTagInclusionExclusion() throws Exception {
io.gravitee.repository.management.model.Api api = new RepositoryApiBuilder().id("api-test").updatedAt(new Date()).definition("test").build();
// api.setTags(new HashSet<>(Arrays.asList(new String[]{"test", "toto"})));
final Api mockApi = mockApi(api);
when(gatewayConfiguration.shardingTags()).thenReturn(Optional.of(Arrays.asList("!test", "toto")));
when(apiRepository.findAll()).thenReturn(Collections.singleton(api));
when(apiManager.apis()).thenReturn(Collections.singleton(mockApi));
final Event mockEvent = mockEvent(api, EventType.PUBLISH_API);
when(eventRepository.search(any(EventCriteria.class), any(Pageable.class))).thenReturn(new Page<>(Collections.singletonList(mockEvent), 0, 0, 1));
syncManager.refresh();
verify(apiManager).deploy(mockApi);
verify(apiManager, never()).update(any(Api.class));
verify(apiManager, never()).undeploy(any(String.class));
}
Aggregations