|
| 1 | +/* |
| 2 | + * Copyright © 2015 The Gravitee team (http://gravitee.io) |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package io.gravitee.apim.infra.domain_service.api; |
| 17 | + |
| 18 | +import static org.assertj.core.api.Assertions.assertThat; |
| 19 | +import static org.mockito.ArgumentMatchers.any; |
| 20 | +import static org.mockito.Mockito.when; |
| 21 | + |
| 22 | +import io.gravitee.apim.core.api.model.import_definition.GraviteeDefinition; |
| 23 | +import io.gravitee.apim.core.audit.model.AuditInfo; |
| 24 | +import io.gravitee.definition.model.v4.ApiType; |
| 25 | +import io.gravitee.rest.api.model.v4.api.ApiEntity; |
| 26 | +import io.gravitee.rest.api.model.v4.api.ExportApiEntity; |
| 27 | +import io.gravitee.rest.api.service.v4.ApiImportExportService; |
| 28 | +import java.util.UUID; |
| 29 | +import org.junit.jupiter.api.Test; |
| 30 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 31 | +import org.mockito.InjectMocks; |
| 32 | +import org.mockito.Mock; |
| 33 | +import org.mockito.junit.jupiter.MockitoExtension; |
| 34 | + |
| 35 | +@ExtendWith(MockitoExtension.class) |
| 36 | +class ApiExportDomainServiceImplTest { |
| 37 | + |
| 38 | + @Mock |
| 39 | + ApiImportExportService exportService; |
| 40 | + |
| 41 | + @InjectMocks |
| 42 | + ApiExportDomainServiceImpl sut; |
| 43 | + |
| 44 | + @Test |
| 45 | + void exportServiceMustMapTypeWhenExportV4() { |
| 46 | + // Given |
| 47 | + String apiId = UUID.randomUUID().toString(); |
| 48 | + ApiEntity api = new ApiEntity(); |
| 49 | + api.setType(ApiType.PROXY); |
| 50 | + when(exportService.exportApi(any(), any(), any(), any())).thenReturn(new ExportApiEntity(api, null, null, null, null, null)); |
| 51 | + |
| 52 | + // When |
| 53 | + GraviteeDefinition export = sut.export(apiId, AuditInfo.builder().build()); |
| 54 | + |
| 55 | + // Then |
| 56 | + assertThat(export.getApi().getType()).isEqualTo(ApiType.PROXY); |
| 57 | + } |
| 58 | +} |
0 commit comments