You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/05/14 09:40:33 UTC

[GitHub] [flink] tillrohrmann commented on a change in pull request #12141: [FLINK-17680][docs] Support @ExcludeFromDocumentation when generating REST API documentations

tillrohrmann commented on a change in pull request #12141:
URL: https://github.com/apache/flink/pull/12141#discussion_r424999798



##########
File path: flink-docs/src/test/java/org/apache/flink/docs/rest/RestAPIDocGeneratorTest.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.docs.rest.data.TestDocumentingRestEndpoint;
+import org.apache.flink.runtime.rest.versioning.RestAPIVersion;
+import org.apache.flink.util.FileUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * Tests for the {@link RestAPIDocGenerator}.
+ */
+public class RestAPIDocGeneratorTest {
+
+	@Test
+	public void testDocGeneration() throws Exception {
+		File file = File.createTempFile("rest_v0_", ".html");
+		RestAPIDocGenerator.createHtmlFile(
+			new TestDocumentingRestEndpoint(),
+			RestAPIVersion.V0,
+			file.toPath());
+		String actual = cleanUpHtml(FileUtils.readFile(file, "UTF-8"));
+
+		File expectedFile = new File(
+			RestAPIDocGeneratorTest.class.getClassLoader().getResource("rest_v0_expected.html").getFile());

Review comment:
       I would be good to have a mean to generate a new `rest_v0_expected.html` in case that it the rest doc generation should change in the future.

##########
File path: flink-docs/src/test/java/org/apache/flink/docs/rest/RestAPIDocGeneratorTest.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.docs.rest.data.TestDocumentingRestEndpoint;
+import org.apache.flink.runtime.rest.versioning.RestAPIVersion;
+import org.apache.flink.util.FileUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * Tests for the {@link RestAPIDocGenerator}.
+ */
+public class RestAPIDocGeneratorTest {
+
+	@Test
+	public void testDocGeneration() throws Exception {
+		File file = File.createTempFile("rest_v0_", ".html");
+		RestAPIDocGenerator.createHtmlFile(
+			new TestDocumentingRestEndpoint(),
+			RestAPIVersion.V0,
+			file.toPath());
+		String actual = cleanUpHtml(FileUtils.readFile(file, "UTF-8"));
+
+		File expectedFile = new File(
+			RestAPIDocGeneratorTest.class.getClassLoader().getResource("rest_v0_expected.html").getFile());
+		String expected = cleanUpHtml(FileUtils.readFile(expectedFile, "UTF-8"));
+
+		Assert.assertEquals(expected, actual);

Review comment:
       This test works as long as `rest_v0_expected.html` is the same as what the `RestAPIDocGenerator` outputs. The problem I see is if we ever need to touch `rest_v0_expected.html`, then we have to make sure that we maintain all the contracts. This means that people need to remember that `@ExcludeFromDocumentation` items should not be listed, for example. A different way of testing this behaviour would to check that `actual` does not contain a message header which is annotated with `@ExcludeFromDocumentation`. This would make the contract more explicit and does not rely on the fact that `rest_v0_expected.html` is actually correct. Otherwise, the test will always pass if `rest_v0_expected.html` and `actual` are actually the same, also if both objects are empty.

##########
File path: flink-docs/src/test/java/org/apache/flink/docs/rest/RestAPIDocGeneratorTest.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.docs.rest.data.TestDocumentingRestEndpoint;
+import org.apache.flink.runtime.rest.versioning.RestAPIVersion;
+import org.apache.flink.util.FileUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * Tests for the {@link RestAPIDocGenerator}.
+ */
+public class RestAPIDocGeneratorTest {

Review comment:
       ```suggestion
   public class RestAPIDocGeneratorTest extends TestLogger {
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org