use of io.gravitee.rest.api.model.configuration.dictionary.DictionaryTriggerEntity in project gravitee-management-rest-api by gravitee-io.
the class DictionaryManagerTest method shouldRestartProviderConfigChanged.
@Test
public void shouldRestartProviderConfigChanged() {
final DictionaryProviderEntity provider = new DictionaryProviderEntity();
provider.setConfiguration(JsonNodeFactory.instance.nullNode());
final DictionaryTriggerEntity trigger = new DictionaryTriggerEntity();
trigger.setRate(1);
trigger.setUnit(TimeUnit.SECONDS);
final DictionaryEntity dictionary = new DictionaryEntity();
dictionary.setUpdatedAt(new Date());
dictionary.setProvider(provider);
dictionary.setId(DICTIONARY_ID);
dictionary.setTrigger(trigger);
final DictionaryProviderEntity providerUpdated = new DictionaryProviderEntity();
providerUpdated.setConfiguration(JsonNodeFactory.instance.arrayNode());
final DictionaryEntity dictionaryUpdated = new DictionaryEntity();
dictionaryUpdated.setUpdatedAt(new Date(ZonedDateTime.now().plusSeconds(60).toInstant().toEpochMilli()));
dictionaryUpdated.setProvider(providerUpdated);
dictionaryUpdated.setId(DICTIONARY_ID);
dictionaryUpdated.setTrigger(trigger);
when(dictionaryService.findById(DICTIONARY_ID)).thenReturn(dictionary).thenReturn(dictionaryUpdated);
cut.start(DICTIONARY_ID);
cut.start(DICTIONARY_ID);
verify(eventManager, times(1)).publishEvent(eq(DictionaryEvent.START), eq(dictionary));
verify(eventManager, times(1)).publishEvent(eq(DictionaryEvent.RESTART), eq(dictionary));
verifyNoMoreInteractions(eventManager);
}
use of io.gravitee.rest.api.model.configuration.dictionary.DictionaryTriggerEntity in project gravitee-management-rest-api by gravitee-io.
the class DictionaryManagerTest method shouldRestartTriggerChanged.
@Test
public void shouldRestartTriggerChanged() {
final DictionaryProviderEntity provider = new DictionaryProviderEntity();
provider.setConfiguration(JsonNodeFactory.instance.nullNode());
final DictionaryTriggerEntity trigger = new DictionaryTriggerEntity();
trigger.setRate(1);
trigger.setUnit(TimeUnit.SECONDS);
final DictionaryEntity dictionary = new DictionaryEntity();
dictionary.setUpdatedAt(new Date());
dictionary.setProvider(provider);
dictionary.setId(DICTIONARY_ID);
dictionary.setTrigger(trigger);
final DictionaryTriggerEntity triggerUpdated = new DictionaryTriggerEntity();
triggerUpdated.setRate(1);
triggerUpdated.setUnit(TimeUnit.MINUTES);
final DictionaryEntity dictionaryUpdated = new DictionaryEntity();
dictionaryUpdated.setUpdatedAt(new Date(ZonedDateTime.now().plusSeconds(60).toInstant().toEpochMilli()));
dictionaryUpdated.setProvider(provider);
dictionaryUpdated.setId(DICTIONARY_ID);
dictionaryUpdated.setTrigger(triggerUpdated);
when(dictionaryService.findById(DICTIONARY_ID)).thenReturn(dictionary).thenReturn(dictionaryUpdated);
cut.start(DICTIONARY_ID);
cut.start(DICTIONARY_ID);
verify(eventManager, times(1)).publishEvent(eq(DictionaryEvent.START), eq(dictionary));
verify(eventManager, times(1)).publishEvent(eq(DictionaryEvent.RESTART), eq(dictionary));
verifyNoMoreInteractions(eventManager);
}
Aggregations