Search in sources :

Example 1 with DictionaryTriggerEntity

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);
}
Also used : DictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryEntity) DictionaryTriggerEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryTriggerEntity) DictionaryProviderEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryProviderEntity) Date(java.util.Date) Test(org.junit.Test)

Example 2 with DictionaryTriggerEntity

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);
}
Also used : DictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryEntity) DictionaryTriggerEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryTriggerEntity) DictionaryProviderEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryProviderEntity) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DictionaryEntity (io.gravitee.rest.api.model.configuration.dictionary.DictionaryEntity)2 DictionaryProviderEntity (io.gravitee.rest.api.model.configuration.dictionary.DictionaryProviderEntity)2 DictionaryTriggerEntity (io.gravitee.rest.api.model.configuration.dictionary.DictionaryTriggerEntity)2 Date (java.util.Date)2 Test (org.junit.Test)2