You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/09/10 21:17:51 UTC

[GitHub] matthiasblaesing commented on a change in pull request #851: [NETBEANS-643] Mercurial Annotate fails on file with spaces and leading dots

matthiasblaesing commented on a change in pull request #851: [NETBEANS-643] Mercurial Annotate fails on file with spaces and leading dots
URL: https://github.com/apache/incubator-netbeans/pull/851#discussion_r216476245
 
 

 ##########
 File path: ide/mercurial/test/unit/src/org/netbeans/modules/mercurial/ui/annotate/AnnotateActionTest.java
 ##########
 @@ -0,0 +1,195 @@
+/*
+ * 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.netbeans.modules.mercurial.ui.annotate;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class AnnotateActionTest {
+
+    private static class AnnotateTestCase {
+        private final String input;
+        private final String expectedUser;
+        private final String exectedRevision;
+        private final String expectedFilename;
+        private final int expectedLineNumber;
+        private final String expectedContent;
+
+        public AnnotateTestCase(String input, String expectedUser, String exectedRevision, String expectedFilename, int expectedLineNumber, String expectedContent) {
+            this.input = input;
+            this.expectedUser = expectedUser;
+            this.exectedRevision = exectedRevision;
+            this.expectedFilename = expectedFilename;
+            this.expectedLineNumber = expectedLineNumber;
+            this.expectedContent = expectedContent;
+        }
+
+        public void runTest(int idx) {
+            AnnotateLine[] resultLines = AnnotateAction.toAnnotateLines(Collections.singletonList(input));
+            assertNotNull(resultLines);
+            assertEquals(1, resultLines.length);
+            AnnotateLine result = resultLines[0];
+            assertNotNull(result);
+
+            assertFalse("Testcase " + idx + " resulted in FakeAnnotationLine", result.getClass().getName().contains("FakeAnnotationLine"));
+            assertEquals("Testcase " + idx, expectedUser, result.getUsername());
+            assertEquals("Testcase " + idx, expectedFilename, result.getFileName());
+            assertEquals("Testcase " + idx, exectedRevision, result.getRevision());
+            assertEquals("Testcase " + idx, expectedLineNumber, result.getPreviousLineNumber());
+            assertEquals("Testcase " + idx, expectedContent, result.getContent());
+        }
+    }
+
+    @Test
+    public void testToAnnotateLines() {
+        List<AnnotateTestCase> testInput = new ArrayList<>();
+        /*
+
+        Testcases were generated on Ubuntu 18.04 and debian Jessie (oldstable
+        by the time of creation). Outputs are marked with a leading ">"
+
+        ------------------------------------------------------------------------
+
+        mkdir sampledir
+        cd sampledir
+
+        > hg --version
 
 Review comment:
   Agreed - thanks for catching that.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists