import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
+import org.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
assertThat(this.producerSimulator.getTestResults().errorFound).isFalse();
}
+ @Test
+ void createApiDoc() throws FileNotFoundException {
+ String url = "/v2/api-docs";
+ ResponseEntity<String> resp = restClient().getForEntity(url).block();
+ assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK);
+
+ String indented = (new JSONObject(resp.getBody())).toString(4);
+ try (PrintStream out = new PrintStream(new FileOutputStream("docs/api.json"))) {
+ out.print(indented);
+ }
+ }
+
@Test
void testGetEiTypes() throws Exception {
putEiProducerWithOneType(EI_PRODUCER_ID, "test");
assertThat(rsp).isEqualTo("[\"test\"]");
}
+ @Test
+ void testGetEiTypesEmpty() throws Exception {
+ String url = ConsumerConsts.API_ROOT + "/eitypes";
+ String rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[]");
+ }
+
@Test
void testGetEiType() throws Exception {
putEiProducerWithOneType(EI_PRODUCER_ID, "test");
String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs";
String rsp = restClient().get(url).block();
assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+ url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=owner";
+ rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+ url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=JUNK";
+ rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[]");
}
@Test
assertThat(this.eiTypes.size()).isEqualTo(0);
}
+ @Test
+ void testGetStatus() throws JsonMappingException, JsonProcessingException, ServiceException {
+ putEiProducerWithOneTypeRejecting("simulateProducerError", EI_TYPE_ID);
+ putEiProducerWithOneTypeRejecting("simulateProducerError2", EI_TYPE_ID);
+
+ String url = "/status";
+ ResponseEntity<String> resp = restClient().getForEntity(url).block();
+ assertThat(resp.getBody()).contains("hunky dory");
+ }
+
ProducerEiTypeRegistrationInfo producerEiTypeRegistrationInfo(String typeId)
throws JsonMappingException, JsonProcessingException {
return new ProducerEiTypeRegistrationInfo(jsonSchemaObject(), typeId);