Skip to content

Commit 7352e82

Browse files
fix: fetch APIs with the correct repository method
1 parent 4d5ec78 commit 7352e82

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/cockpit/command/handler/DeployModelCommandHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import io.gravitee.cockpit.api.command.v1.designer.DeployModelReply;
2929
import io.gravitee.definition.model.DefinitionVersion;
3030
import io.gravitee.exchange.api.command.CommandHandler;
31+
import io.gravitee.repository.management.model.Api;
3132
import io.gravitee.rest.api.model.EnvironmentEntity;
3233
import io.gravitee.rest.api.model.UserEntity;
33-
import io.gravitee.rest.api.model.v4.api.ApiEntity;
3434
import io.gravitee.rest.api.service.EnvironmentService;
3535
import io.gravitee.rest.api.service.UserService;
3636
import io.gravitee.rest.api.service.cockpit.model.DeploymentMode;
@@ -106,7 +106,7 @@ public Single<DeployModelReply> handle(DeployModelCommand command) {
106106
return message
107107
.map(s -> Single.just(new DeployModelReply(command.getId(), s)))
108108
.orElseGet(() -> {
109-
final ApiEntity api = apiSearchService.findById(executionContext, apiId);
109+
final Api api = apiSearchService.findRepositoryApiById(executionContext, apiId);
110110

111111
if (api.getDefinitionVersion() == DefinitionVersion.V2) {
112112
return updateV2Api(command, apiId, executionContext, user, mode, swaggerDefinition, labels);

gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/cockpit/command/handler/DeployModelCommandHandlerTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.gravitee.cockpit.api.command.v1.designer.DeployModelReply;
3030
import io.gravitee.definition.model.DefinitionVersion;
3131
import io.gravitee.exchange.api.command.CommandStatus;
32+
import io.gravitee.repository.management.model.Api;
3233
import io.gravitee.rest.api.model.EnvironmentEntity;
3334
import io.gravitee.rest.api.model.UserEntity;
3435
import io.gravitee.rest.api.model.api.ApiEntity;
@@ -105,8 +106,8 @@ public void updates_an_API_DOCUMENTED() {
105106

106107
String apiId = "api#id";
107108
when(apiSearchService.findIdByEnvironmentIdAndCrossId(ENVIRONMENT_ID, payload.modelId())).thenReturn(Optional.of(apiId));
108-
when(apiSearchService.findById(EXECUTION_CONTEXT, apiId)).thenReturn(
109-
io.gravitee.rest.api.model.v4.api.ApiEntity.builder().definitionVersion(DefinitionVersion.V2).build()
109+
when(apiSearchService.findRepositoryApiById(EXECUTION_CONTEXT, apiId)).thenReturn(
110+
Api.builder().definitionVersion(DefinitionVersion.V2).build()
110111
);
111112

112113
UserEntity user = createUserEntity(payload);
@@ -146,8 +147,8 @@ public void updates_an_API_MOCKED_mode() {
146147

147148
String apiId = "api#id";
148149
when(apiSearchService.findIdByEnvironmentIdAndCrossId(ENVIRONMENT_ID, payload.modelId())).thenReturn(Optional.of(apiId));
149-
when(apiSearchService.findById(EXECUTION_CONTEXT, apiId)).thenReturn(
150-
io.gravitee.rest.api.model.v4.api.ApiEntity.builder().definitionVersion(DefinitionVersion.V2).build()
150+
when(apiSearchService.findRepositoryApiById(EXECUTION_CONTEXT, apiId)).thenReturn(
151+
Api.builder().definitionVersion(DefinitionVersion.V2).build()
151152
);
152153

153154
UserEntity user = createUserEntity(payload);
@@ -187,8 +188,8 @@ public void updates_an_API_PUBLISHED_mode() {
187188

188189
String apiId = "api#id";
189190
when(apiSearchService.findIdByEnvironmentIdAndCrossId(ENVIRONMENT_ID, payload.modelId())).thenReturn(Optional.of(apiId));
190-
when(apiSearchService.findById(EXECUTION_CONTEXT, apiId)).thenReturn(
191-
io.gravitee.rest.api.model.v4.api.ApiEntity.builder().definitionVersion(DefinitionVersion.V2).build()
191+
when(apiSearchService.findRepositoryApiById(EXECUTION_CONTEXT, apiId)).thenReturn(
192+
Api.builder().definitionVersion(DefinitionVersion.V2).build()
192193
);
193194

194195
UserEntity user = createUserEntity(payload);

gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/cockpit/command/handler/DeployModelV4CommandHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ public void update_API(DeployModelCommandPayload.DeploymentMode deploymentMode,
196196
).thenReturn(Optional.empty());
197197

198198
when(apiSearchService.findIdByEnvironmentIdAndCrossId(ENVIRONMENT_ID, payload.modelId())).thenReturn(Optional.of(apiId));
199-
when(apiSearchService.findById(EXECUTION_CONTEXT, apiId)).thenReturn(
200-
io.gravitee.rest.api.model.v4.api.ApiEntity.builder().definitionVersion(DefinitionVersion.V4).build()
199+
when(apiSearchService.findRepositoryApiById(EXECUTION_CONTEXT, apiId)).thenReturn(
200+
io.gravitee.repository.management.model.Api.builder().definitionVersion(DefinitionVersion.V4).build()
201201
);
202202

203203
when(deployModelToApiUpdateUseCase.execute(any())).thenReturn(new DeployModelToApiUpdateUseCase.Output(new Api()));

0 commit comments

Comments
 (0)