1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.io;
|
---|
3 |
|
---|
4 | import static org.hamcrest.CoreMatchers.containsString;
|
---|
5 | import static org.hamcrest.MatcherAssert.assertThat;
|
---|
6 |
|
---|
7 | import javax.swing.JLabel;
|
---|
8 | import javax.swing.JTextField;
|
---|
9 |
|
---|
10 | import org.junit.jupiter.api.Test;
|
---|
11 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
---|
12 |
|
---|
13 | @BasicPreferences
|
---|
14 | class UploadTextComponentValidatorTest {
|
---|
15 | /**
|
---|
16 | * Unit test of {@link UploadTextComponentValidator.UploadCommentValidator}
|
---|
17 | */
|
---|
18 | @Test
|
---|
19 | void testUploadCommentValidator() {
|
---|
20 | JTextField textField = new JTextField();
|
---|
21 | JLabel feedback = new JLabel();
|
---|
22 | new UploadTextComponentValidator.UploadCommentValidator(textField, feedback);
|
---|
23 | assertThat(feedback.getText(), containsString("Your upload comment is <i>empty</i>, or <i>very short</i>"));
|
---|
24 | textField.setText("a comment long enough");
|
---|
25 | assertThat(feedback.getText(), containsString("Thank you for providing a changeset comment"));
|
---|
26 | textField.setText("a");
|
---|
27 | assertThat(feedback.getText(), containsString("Your upload comment is <i>empty</i>, or <i>very short</i>"));
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Unit test of {@link UploadTextComponentValidator.UploadSourceValidator}
|
---|
32 | */
|
---|
33 | @Test
|
---|
34 | void testUploadSourceValidator() {
|
---|
35 | JTextField textField = new JTextField();
|
---|
36 | JLabel feedback = new JLabel();
|
---|
37 | new UploadTextComponentValidator.UploadSourceValidator(textField, feedback);
|
---|
38 | assertThat(feedback.getText(), containsString("You did not specify a source for your changes"));
|
---|
39 | textField.setText("a comment long enough");
|
---|
40 | assertThat(feedback.getText(), containsString("Thank you for providing the data source"));
|
---|
41 | }
|
---|
42 | }
|
---|