Skip to content

Commit

Permalink
[news] added supported protocols to unsupported protocol error message
Browse files Browse the repository at this point in the history
Bug: 473163
Change-Id: I2e306aa659e2cab796534f457431f99326e4b20a
Signed-off-by: Pawel Nowak <siersciotluk@gmail.com>
  • Loading branch information
cybuch authored and JohannesDorn committed Jul 27, 2015
1 parent 60b284e commit 5317abc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Expand Up @@ -27,12 +27,16 @@
import org.eclipse.swt.widgets.Text;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;

public class FeedDialog extends TitleAreaDialog {
private static final List<String> ACCEPTED_PROTOCOLS = ImmutableList.of("http", "https"); //$NON-NLS-1$ , //$NON-NLS-2$

@VisibleForTesting
static final List<String> ACCEPTED_PROTOCOLS = ImmutableList.of("http", "https"); //$NON-NLS-1$ , //$NON-NLS-2$

private final List<FeedDescriptor> existingDescriptors;
private FeedDescriptor feed;
private Text nameValue;
Expand Down Expand Up @@ -171,7 +175,8 @@ static String validateFeedDialog(FeedDescriptor currentFeed, String name, String
} else if (parseUriQuietly(url).orNull() == null) {
return Messages.FEED_DIALOG_ERROR_INVALID_URL;
} else if (!isUriProtocolSupported(parseUriQuietly(url).orNull(), ACCEPTED_PROTOCOLS)) {
return MessageFormat.format(Messages.FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED, url);
return MessageFormat.format(Messages.FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED, url,
Joiner.on(", ").join(ACCEPTED_PROTOCOLS)); //$NON-NLS-1$
} else if (duplicateFeed != null) {
return MessageFormat.format(Messages.FEED_DIALOG_ERROR_DUPLICATE_FEED, duplicateFeed.getName());
} else if (!pollingInterval.matches("[0-9]+")) { //$NON-NLS-1$
Expand Down
Expand Up @@ -18,7 +18,8 @@ FIELD_LABEL_NOTIFICATION_ENABLED=Enable Mylyn Notification that will display new
FIELD_LABEL_POLLING_INTERVAL=Polling interval (minutes):
FEED_DIALOG_ERROR_EMPTY_NAME=Name is empty.
FEED_DIALOG_ERROR_EMPTY_URL=URL is empty.
FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED=The protocol \u2018{0}\u2019 is not supported.
FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED=The protocol \u2018{0}\u2019 is not supported. \
Supported protocols are: \u2018{1}\u2019
FEED_DIALOG_ERROR_INVALID_URL=URL is invalid.
FEED_DIALOG_ERROR_POLLING_INTERVAL_DIGITS_ONLY=Polling interval must be digits only.
FEED_DIALOG_ERROR_DUPLICATE_FEED=Feed \u2018{0}\u2019 already uses this URL.
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import com.google.common.base.Joiner;
import com.google.common.collect.Lists;

@RunWith(Parameterized.class)
Expand Down Expand Up @@ -61,7 +62,8 @@ public static Collection<Object[]> scenarios() {
scenarios.add(new Object[] { null, VALID_FEED_NAME, EMPTY_STRING, EMPTY_STRING,
Messages.FEED_DIALOG_ERROR_EMPTY_URL });
scenarios.add(new Object[] { null, VALID_FEED_NAME, INVALID_FEED_PROTOCOL, EMPTY_STRING,
MessageFormat.format(Messages.FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED, INVALID_FEED_PROTOCOL) });
MessageFormat.format(Messages.FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED, INVALID_FEED_PROTOCOL,
Joiner.on(", ").join(FeedDialog.ACCEPTED_PROTOCOLS)) });
scenarios.add(new Object[] { null, VALID_FEED_NAME, INVALID_FEED_URL, EMPTY_STRING,
Messages.FEED_DIALOG_ERROR_INVALID_URL });
scenarios.add(new Object[] { null, VALID_FEED_NAME, DUPLICATE_FEED_URL, EMPTY_STRING,
Expand Down
Expand Up @@ -28,6 +28,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import com.google.common.base.Joiner;

@RunWith(SWTBotJunit4ClassRunner.class)
public class NewsPreferencePageUITest {
private static final String VALID_FEED_NAME = "feed"; //$NON-NLS-1$
Expand Down Expand Up @@ -121,8 +123,8 @@ public void testAddCustomFeedWithInvalidProtocol() {
bot.textWithLabel(Messages.FIELD_LABEL_URL).setText(INVALID_FEED_PROTOCOL);

assertThat(
bot.text(" "
+ MessageFormat.format(Messages.FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED, INVALID_FEED_PROTOCOL)),
bot.text(" " + MessageFormat.format(Messages.FEED_DIALOG_ERROR_PROTOCOL_UNSUPPORTED,
INVALID_FEED_PROTOCOL, Joiner.on(", ").join(FeedDialog.ACCEPTED_PROTOCOLS))),
is(notNullValue()));
assertThat(bot.button("OK").isEnabled(), is(false)); //$NON-NLS-1$
}
Expand Down

0 comments on commit 5317abc

Please sign in to comment.