Search in sources :

Example 11 with Parameter

use of io.gravitee.repository.management.model.Parameter in project gravitee-management-rest-api by gravitee-io.

the class ParameterServiceTest method shouldFindAll.

@Test
public void shouldFindAll() throws TechnicalException {
    final Parameter parameter = new Parameter();
    parameter.setKey(PARAMETER_KEY);
    parameter.setValue("api1;api2");
    when(parameterRepository.findById(PARAMETER_KEY)).thenReturn(of(parameter));
    final List<String> values = parameterService.findAll(PARAMETER_KEY, value -> value);
    assertEquals(asList("api1", "api2"), values);
}
Also used : Parameter(io.gravitee.repository.management.model.Parameter) Test(org.junit.Test)

Example 12 with Parameter

use of io.gravitee.repository.management.model.Parameter in project gravitee-management-rest-api by gravitee-io.

the class ParameterServiceTest method shouldUpdate.

@Test
public void shouldUpdate() throws TechnicalException {
    final Parameter parameter = new Parameter();
    parameter.setKey(PARAMETER_KEY);
    parameter.setValue("api1");
    final Parameter newParameter = new Parameter();
    newParameter.setKey(PARAMETER_KEY);
    newParameter.setValue("api2");
    when(parameterRepository.findById(PARAMETER_KEY)).thenReturn(of(parameter));
    when(parameterRepository.update(newParameter)).thenReturn(newParameter);
    parameterService.update(PARAMETER_KEY, "api2");
    verify(parameterRepository).update(newParameter);
    verify(auditService).createPortalAuditLog(eq(singletonMap(PARAMETER, PARAMETER_KEY)), eq(PARAMETER_UPDATED), any(), eq(parameter), eq(newParameter));
}
Also used : Parameter(io.gravitee.repository.management.model.Parameter) Test(org.junit.Test)

Aggregations

Parameter (io.gravitee.repository.management.model.Parameter)12 Test (org.junit.Test)9 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)3 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)3 Date (java.util.Date)2 ParameterAlreadyExistsException (io.gravitee.management.service.exceptions.ParameterAlreadyExistsException)1 ParameterNotFoundException (io.gravitee.management.service.exceptions.ParameterNotFoundException)1