Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* This intrinsic observation source plug-in retrieves AID observations via the
* VSX web service.
*/
@Deprecated
public class AIDWebServiceXMLAttributeObservationSourcePlugin extends
AIDWebServiceObservationSourcePluginBase {

Expand Down Expand Up @@ -336,7 +337,7 @@

ob = new ValidObservation();

if (id != null) {

Check warning on line 340 in src/org/aavso/tools/vstar/plugin/ob/src/impl/AIDWebServiceXMLAttributeObservationSourcePlugin.java

View workflow job for this annotation

GitHub Actions / SpotBugs

RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE

Redundant nullcheck of id, which is known to be non-null in org.aavso.tools.vstar.plugin.ob.src.impl.AIDWebServiceXMLAttributeObservationSourcePlugin$VSXAIDAttributeObservationRetriever.retrieveObservation(INodeSequence)
Raw output
This method contains a redundant check of a known non-null value against the constant null.

Check warning on line 340 in src/org/aavso/tools/vstar/plugin/ob/src/impl/AIDWebServiceXMLAttributeObservationSourcePlugin.java

View workflow job for this annotation

GitHub Actions / SpotBugs

RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE

Redundant nullcheck of id, which is known to be non-null in org.aavso.tools.vstar.plugin.ob.src.impl.AIDWebServiceXMLAttributeObservationSourcePlugin$VSXAIDAttributeObservationRetriever.retrieveObservation(INodeSequence)
Raw output
This method contains a redundant check of a known non-null value against the constant null.
ob.setRecordNumber(id);
}

Expand Down
52 changes: 35 additions & 17 deletions src/org/aavso/tools/vstar/ui/dialog/InfoDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,50 @@
* The loaded star messages.
*/
public InfoDialog(List<NewStarMessage> newStarMessages) {
this(newStarMessages, true);
}

/**
* Package-private constructor that allows tests to build the dialog without
* displaying it. When {@code show} is {@code false} all Swing setup,
* {@code setLocationRelativeTo}, and {@code setVisible(true)} are skipped so
* that the dialog can be constructed without a live {@code Mediator} UI.
*
* @param newStarMessages
* The loaded star messages (ignored when show is false).
* @param show
* {@code true} to build and display normally; {@code false} for
* tests.
*/
InfoDialog(List<NewStarMessage> newStarMessages, boolean show) {
super(DocumentManager.findActiveWindow());
this.setTitle("Information");

JPanel topPane = new JPanel();
topPane.setLayout(new BoxLayout(topPane, BoxLayout.PAGE_AXIS));
topPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
if (show) {
JPanel topPane = new JPanel();
topPane.setLayout(new BoxLayout(topPane, BoxLayout.PAGE_AXIS));
topPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

JScrollPane scrollPane = new JScrollPane(
createInfoPanel(newStarMessages));
topPane.add(scrollPane);
JScrollPane scrollPane = new JScrollPane(
createInfoPanel(newStarMessages));
topPane.add(scrollPane);

topPane.add(Box.createRigidArea(new Dimension(10, 10)));
topPane.add(Box.createRigidArea(new Dimension(10, 10)));

JPanel buttonPane = new JPanel();
JButton dismissButton = new JButton("Dismiss");
dismissButton.addActionListener(this);
buttonPane.add(dismissButton, BorderLayout.CENTER);
topPane.add(buttonPane);
JPanel buttonPane = new JPanel();
JButton dismissButton = new JButton("Dismiss");
dismissButton.addActionListener(this);
buttonPane.add(dismissButton, BorderLayout.CENTER);
topPane.add(buttonPane);

this.getContentPane().add(topPane);
this.getContentPane().add(topPane);

this.getRootPane().setDefaultButton(dismissButton);
this.getRootPane().setDefaultButton(dismissButton);

this.pack();
this.setLocationRelativeTo(Mediator.getUI().getContentPane());
this.setVisible(true);
this.pack();
this.setLocationRelativeTo(Mediator.getUI().getContentPane());
this.setVisible(true);
}
}

/**
Expand Down Expand Up @@ -110,7 +128,7 @@
.getObsCategoryMap();

for (SeriesType type : obsCategoryMap.keySet()) {
List<ValidObservation> obsOfType = obsCategoryMap.get(type);

Check warning on line 131 in src/org/aavso/tools/vstar/ui/dialog/InfoDialog.java

View workflow job for this annotation

GitHub Actions / SpotBugs

WMI_WRONG_MAP_ITERATOR

org.aavso.tools.vstar.ui.dialog.InfoDialog.createInfoPanel(List) makes inefficient use of keySet iterator instead of entrySet iterator
Raw output
This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.

Check warning on line 131 in src/org/aavso/tools/vstar/ui/dialog/InfoDialog.java

View workflow job for this annotation

GitHub Actions / SpotBugs

WMI_WRONG_MAP_ITERATOR

org.aavso.tools.vstar.ui.dialog.InfoDialog.createInfoPanel(List) makes inefficient use of keySet iterator instead of entrySet iterator
Raw output
This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.
if (!obsOfType.isEmpty()) {
seriesBuf.append(type.getDescription());
seriesBuf.append(": ");
Expand All @@ -122,7 +140,7 @@
seriesTextArea.setText(seriesBuf.toString());

// Statistics
JTextArea statsTextArea = new JTextArea();

Check warning on line 143 in src/org/aavso/tools/vstar/ui/dialog/InfoDialog.java

View workflow job for this annotation

GitHub Actions / SpotBugs

DLS_DEAD_LOCAL_STORE

Dead store to statsTextArea in org.aavso.tools.vstar.ui.dialog.InfoDialog.createInfoPanel(List)
Raw output
This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.

Note that Sun's javac compiler often generates dead stores for final local variables. Because SpotBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.

Check warning on line 143 in src/org/aavso/tools/vstar/ui/dialog/InfoDialog.java

View workflow job for this annotation

GitHub Actions / SpotBugs

DLS_DEAD_LOCAL_STORE

Dead store to statsTextArea in org.aavso.tools.vstar.ui.dialog.InfoDialog.createInfoPanel(List)
Raw output
This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.

Note that Sun's javac compiler often generates dead stores for final local variables. Because SpotBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.
// We don't include this now. See Current Mode ANOVA plugin.
if (false) {
statsTextArea.setEditable(false);
Expand Down
16 changes: 16 additions & 0 deletions test/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,25 @@
import org.aavso.tools.vstar.ui.dialog.DateToJdDialogTest;
import org.aavso.tools.vstar.ui.dialog.DiscrepantReportDialogTest;
import org.aavso.tools.vstar.ui.dialog.DoubleFieldTest;
import org.aavso.tools.vstar.ui.dialog.FileExtensionFilterTest;
import org.aavso.tools.vstar.ui.dialog.InfoDialogTest;
import org.aavso.tools.vstar.ui.dialog.MultiEntryComponentDialogTest;
import org.aavso.tools.vstar.ui.dialog.PeriodAnalysisPluginDialogsTest;
import org.aavso.tools.vstar.ui.dialog.PhaseParameterDialogTest;
import org.aavso.tools.vstar.ui.dialog.PolynomialDegreeDialogTest;
import org.aavso.tools.vstar.ui.dialog.RadioButtonDialogTest;
import org.aavso.tools.vstar.ui.dialog.SeriesTypeCreationDialogTest;
import org.aavso.tools.vstar.ui.dialog.TextDialogTest;
import org.aavso.tools.vstar.ui.dialog.period.PeriodAnalysis2DChartPaneTest;
import org.aavso.tools.vstar.ui.model.list.AAVSOFormatRawDataColumnInfoSourceTest;
import org.aavso.tools.vstar.ui.model.list.AbstractSyntheticObservationTableModelTest;
import org.aavso.tools.vstar.ui.model.list.PeriodAnalysisDataTableModelTest;
import org.aavso.tools.vstar.ui.model.list.ValidObservationTableModelTest;
import org.aavso.tools.vstar.ui.model.list.WWZDataTableModelTest;
import org.aavso.tools.vstar.ui.model.plot.ObservationAndMeanPlotModelTest;
import org.aavso.tools.vstar.ui.pane.list.ListSearchPaneTest;
import org.aavso.tools.vstar.ui.pane.list.ObservationListPaneTest;
import org.aavso.tools.vstar.ui.pane.list.SyntheticObservationListPaneTest;
import org.aavso.tools.vstar.ui.pane.list.VisibleSeriesRowFilterTest;
import org.aavso.tools.vstar.vela.VeLaTest;

Expand Down Expand Up @@ -139,19 +147,27 @@ public static Test suite() {
suite.addTestSuite(PeriodAnalysisDataTableModelTest.class);
suite.addTestSuite(WWZDataTableModelTest.class);
suite.addTestSuite(AbstractSyntheticObservationTableModelTest.class);
suite.addTestSuite(ListSearchPaneTest.class);
suite.addTestSuite(ObservationListPaneTest.class);
suite.addTestSuite(SyntheticObservationListPaneTest.class);
suite.addTestSuite(VisibleSeriesRowFilterTest.class);
suite.addTestSuite(DateToJdDialogTest.class);
suite.addTestSuite(TextDialogTest.class);
suite.addTestSuite(AbstractOkCancelDialogTest.class);
suite.addTestSuite(AboutBoxTest.class);
suite.addTestSuite(DoubleFieldTest.class);
suite.addTestSuite(FileExtensionFilterTest.class);
suite.addTestSuite(MultiEntryComponentDialogTest.class);
suite.addTestSuite(PolynomialDegreeDialogTest.class);
suite.addTestSuite(RadioButtonDialogTest.class);
suite.addTestSuite(DiscrepantReportDialogTest.class);
suite.addTestSuite(PhaseParameterDialogTest.class);
suite.addTestSuite(SeriesTypeCreationDialogTest.class);
suite.addTestSuite(PeriodAnalysisPluginDialogsTest.class);
suite.addTestSuite(InfoDialogTest.class);
suite.addTestSuite(AAVSOFormatRawDataColumnInfoSourceTest.class);
suite.addTestSuite(ObservationAndMeanPlotModelTest.class);
suite.addTestSuite(PeriodAnalysis2DChartPaneTest.class);
// $JUnit-END$

return suite;
Expand Down
64 changes: 64 additions & 0 deletions test/org/aavso/tools/vstar/ui/dialog/FileExtensionFilterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* VStar: a statistical analysis tool for variable star data.
* Copyright (C) 2009 AAVSO (http://www.aavso.org/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.aavso.tools.vstar.ui.dialog;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import junit.framework.TestCase;

/**
* Unit tests for {@link FileExtensionFilter}.
*/
public class FileExtensionFilterTest extends TestCase {

private static final List<String> EXTENSIONS = Arrays.asList(".csv", ".txt");

private FileExtensionFilter filter;

@Override
protected void setUp() {
filter = new FileExtensionFilter(EXTENSIONS);
}

public void testDirectoryIsAlwaysAccepted() {
File dir = new File(System.getProperty("java.io.tmpdir"));
assertTrue("A directory should always be accepted", filter.accept(dir));
}

public void testFileWithMatchingExtensionIsAccepted() {
File f = new File("data.csv");
assertTrue("A file with a matching extension should be accepted", filter.accept(f));
}

public void testFileWithMatchingExtensionCaseInsensitive() {
File f = new File("data.TXT");
assertTrue("Extension matching should be case-insensitive", filter.accept(f));
}

public void testFileWithNonMatchingExtensionIsRejected() {
File f = new File("data.xml");
assertFalse("A file with a non-matching extension should be rejected", filter.accept(f));
}

public void testFileWithNoExtensionIsRejected() {
File f = new File("datafile");
assertFalse("A file with no extension should be rejected", filter.accept(f));
}
}
65 changes: 65 additions & 0 deletions test/org/aavso/tools/vstar/ui/dialog/InfoDialogTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* VStar: a statistical analysis tool for variable star data.
* Copyright (C) 2009 AAVSO (http://www.aavso.org/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.aavso.tools.vstar.ui.dialog;

import java.util.Collections;
import java.util.Locale;

import junit.framework.TestCase;

/**
* Tests for {@link InfoDialog}.
*
* Uses the package-private {@code InfoDialog(messages, show=false)} constructor
* to build the dialog without displaying it, bypassing the
* {@code Mediator.getUI()} call and the blocking {@code setVisible(true)}.
*
* Note: text-content testing would require a fully populated
* {@link org.aavso.tools.vstar.ui.mediator.message.NewStarMessage} with a
* concrete {@link org.aavso.tools.vstar.input.AbstractObservationRetriever};
* title and modal-flag verification are sufficient to exercise the constructor
* path without that complexity.
*
* Part of issue #579 (GUI code coverage, prong D).
*/
public class InfoDialogTest extends TestCase {

@Override
protected void setUp() {
Locale.setDefault(Locale.ENGLISH);
}

public void testTitle() {
InfoDialog dialog = new InfoDialog(Collections.emptyList(), false);
try {
assertEquals("Information", dialog.getTitle());
} finally {
dialog.dispose();
}
}

public void testNotModal() {
InfoDialog dialog = new InfoDialog(Collections.emptyList(), false);
try {
assertFalse("InfoDialog should not be modal by default",
dialog.isModal());
} finally {
dialog.dispose();
}
}
}
Loading
Loading