fix(firstleg): publish sailing edit and history paths
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
package com.baiyue.firstleg.sailingcalendar.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class SailingCalendarOpenApiContractTest {
|
||||
@Test
|
||||
void publishesEditAndHistoryOnTheControllerPaths() throws Exception {
|
||||
String yaml = new ClassPathResource("openapi/sailing-calendar-v1.yaml")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
String editPath = "/api/platform/v1/sailings/{id}:";
|
||||
String historyPath = "/api/platform/v1/sailings/{id}/history:";
|
||||
int editStart = yaml.indexOf(editPath);
|
||||
int historyStart = yaml.indexOf(historyPath);
|
||||
|
||||
assertThat(editStart).isGreaterThanOrEqualTo(0);
|
||||
assertThat(historyStart).isGreaterThan(editStart);
|
||||
String editBlock = yaml.substring(editStart, historyStart);
|
||||
String historyBlock = yaml.substring(historyStart);
|
||||
int nextPath = historyBlock.indexOf("\n /api/");
|
||||
if (nextPath >= 0) historyBlock = historyBlock.substring(0, nextPath);
|
||||
|
||||
assertThat(editBlock)
|
||||
.contains(" put:")
|
||||
.contains("x-permission: platform:firstleg:sailing-calendar:edit");
|
||||
assertThat(historyBlock)
|
||||
.contains(" get:")
|
||||
.contains("summary: 查询船期变更历史")
|
||||
.doesNotContain(" put:");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user