Search in sources :

Example 1 with UpdateTopApiEntity

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

the class TopApiServiceTest method shouldUpdate.

@Test
public void shouldUpdate() {
    final UpdateTopApiEntity topApi = new UpdateTopApiEntity();
    topApi.setApi("api");
    topApi.setOrder(2);
    final UpdateTopApiEntity topApi2 = new UpdateTopApiEntity();
    topApi2.setApi("api2");
    topApi.setOrder(1);
    when(parameterService.findAll(PORTAL_TOP_APIS, ParameterReferenceType.ENVIRONMENT)).thenReturn(asList("api", "api2"));
    topApiService.update(asList(topApi, topApi2));
    verify(parameterService).save(PORTAL_TOP_APIS, asList("api2", "api"), ParameterReferenceType.ENVIRONMENT);
    verify(parameterService).findAll(eq(PORTAL_TOP_APIS), any(Function.class), any(Predicate.class), any(ParameterReferenceType.class));
}
Also used : Function(java.util.function.Function) ParameterReferenceType(io.gravitee.rest.api.model.parameters.ParameterReferenceType) UpdateTopApiEntity(io.gravitee.rest.api.model.UpdateTopApiEntity) Predicate(java.util.function.Predicate) Test(org.junit.Test)

Example 2 with UpdateTopApiEntity

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

the class TopApiServiceTest method shouldNotUpdate.

@Test(expected = IllegalArgumentException.class)
public void shouldNotUpdate() {
    final UpdateTopApiEntity topApi = new UpdateTopApiEntity();
    topApi.setApi("api");
    topApi.setOrder(2);
    final UpdateTopApiEntity topApi2 = new UpdateTopApiEntity();
    topApi2.setApi("api2");
    topApi.setOrder(1);
    when(parameterService.findAll(PORTAL_TOP_APIS, ParameterReferenceType.ENVIRONMENT)).thenReturn(singletonList("api"));
    topApiService.update(asList(topApi, topApi2));
}
Also used : UpdateTopApiEntity(io.gravitee.rest.api.model.UpdateTopApiEntity) Test(org.junit.Test)

Aggregations

UpdateTopApiEntity (io.gravitee.rest.api.model.UpdateTopApiEntity)2 Test (org.junit.Test)2 ParameterReferenceType (io.gravitee.rest.api.model.parameters.ParameterReferenceType)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1