From 815cb09dc2fdc35cb9c1bb5b552275ed891b8663 Mon Sep 17 00:00:00 2001 From: Mungo Carstairs Date: Tue, 22 Oct 2019 15:50:52 +0100 Subject: [PATCH] JAL-3423 use System.lineSeparator() in code and tests --- src/jalview/analysis/AlignSeq.java | 20 +++++++--------- test/jalview/gui/PairwiseAlignmentPanelTest.java | 28 ++++++++++++---------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 1b2578e..38adeee 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -565,8 +565,8 @@ public class AlignSeq } pid = pid / (aseq1.length - count) * 100; - output.append(new Format("Percentage ID = %3.2f\n").form(pid)); - output.append(NEWLINE); + output.append(new Format("Percentage ID = %3.2f").form(pid)); + output.append(NEWLINE).append(NEWLINE); try { os.print(output.toString()); @@ -862,8 +862,8 @@ public class AlignSeq */ public jalview.datamodel.Mapping getMappingFromS1(boolean allowmismatch) { - ArrayList as1 = new ArrayList(), - as2 = new ArrayList(); + ArrayList as1 = new ArrayList<>(), + as2 = new ArrayList<>(); int pdbpos = s2.getStart() + getSeq2Start() - 2; int alignpos = s1.getStart() + getSeq1Start() - 2; int lp2 = pdbpos - 3, lp1 = alignpos - 3; @@ -914,13 +914,11 @@ public class AlignSeq { mapseq1[i++] = ip; } - ; i = 0; for (Integer ip : as2) { mapseq2[i++] = ip; } - ; if (lastmatch) { mapseq1[mapseq1.length - 1] = alignpos; @@ -951,13 +949,13 @@ public class AlignSeq List ochains, AlignmentI al, String dnaOrProtein, boolean removeOldAnnots) { - List orig = new ArrayList(), - repl = new ArrayList(); - List aligs = new ArrayList(); + List orig = new ArrayList<>(), + repl = new ArrayList<>(); + List aligs = new ArrayList<>(); if (al != null && al.getHeight() > 0) { - ArrayList matches = new ArrayList(); - ArrayList aligns = new ArrayList(); + ArrayList matches = new ArrayList<>(); + ArrayList aligns = new ArrayList<>(); for (SequenceI sq : ochains) { diff --git a/test/jalview/gui/PairwiseAlignmentPanelTest.java b/test/jalview/gui/PairwiseAlignmentPanelTest.java index e74849f..14ab3d6 100644 --- a/test/jalview/gui/PairwiseAlignmentPanelTest.java +++ b/test/jalview/gui/PairwiseAlignmentPanelTest.java @@ -15,6 +15,8 @@ import junit.extensions.PA; public class PairwiseAlignmentPanelTest { + private static final String NL = System.lineSeparator(); + @Test(groups = "Functional") public void testConstructor_withSelectionGroup() { @@ -38,12 +40,13 @@ public class PairwiseAlignmentPanelTest PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport); String text = ((JTextArea) PA.getValue(testee, "textarea")).getText() - .replaceAll("\r", ""); - String expected = "Score = 80.0\n" + "Length of alignment = 4\n" - + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n" - + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n" - + " FER1_PEA/29-32 TKAF\n" + " ||.\n" - + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n"; + ;// .replaceAll("\r", ""); + String expected = "Score = 80.0" + NL + "Length of alignment = 4" + NL + + "Sequence FER1_PEA/29-32 (Sequence length = 7)" + NL + + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)" + NL + NL + + " FER1_PEA/29-32 TKAF" + NL + " ||." + + NL + "Q93XJ9_SOLTU/23-26 LKAI" + NL + NL + + "Percentage ID = 50.00" + NL + NL; assertEquals(text, expected); } @@ -64,12 +67,13 @@ public class PairwiseAlignmentPanelTest PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport); String text = ((JTextArea) PA.getValue(testee, "textarea")).getText() - .replaceAll("\r", ""); - String expected = "Score = 80.0\n" + "Length of alignment = 4\n" - + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n" - + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n" - + " FER1_PEA/29-32 TKAF\n" + " ||.\n" - + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n"; + ;// .replaceAll("\r", ""); + String expected = "Score = 80.0" + NL + "Length of alignment = 4" + NL + + "Sequence FER1_PEA/29-32 (Sequence length = 7)" + NL + + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)" + NL + NL + + " FER1_PEA/29-32 TKAF" + NL + " ||." + + NL + "Q93XJ9_SOLTU/23-26 LKAI" + NL + NL + + "Percentage ID = 50.00" + NL + NL; assertEquals(text, expected); } } -- 1.7.10.2