Code style fixes

This commit is contained in:
cketti 2017-01-12 06:28:32 +01:00
parent f457de3821
commit 25d977a813
2 changed files with 32 additions and 19 deletions

View file

@ -134,7 +134,6 @@ public class SettingsImporter {
// will not be null.
if (imported.accounts != null) {
for (ImportedAccount account : imported.accounts.values()) {
//Show a alternative text in the case the description is empty
String name = account.name;
if (TextUtils.isEmpty(name) && account.identities != null && account.identities.size() > 0){
name = account.identities.get(0).email;
@ -942,7 +941,6 @@ public class SettingsImporter {
account.settings = parseSettings(xpp, SettingsExporter.SETTINGS_ELEMENT);
}
} else if (SettingsExporter.IDENTITIES_ELEMENT.equals(element)) {
//Read the full content to have an alternative identifier to display if the name is empty
account.identities = parseIdentities(xpp);
} else if (SettingsExporter.FOLDERS_ELEMENT.equals(element)) {
if (overview) {

View file

@ -1,9 +1,14 @@
package com.fsck.k9.preferences;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.fsck.k9.Account;
import com.fsck.k9.Preferences;
import com.fsck.k9.mail.AuthType;
import org.apache.tools.ant.filters.StringInputStream;
import org.junit.Before;
import org.junit.Test;
@ -12,14 +17,10 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@SuppressWarnings("unchecked")
@RunWith(RobolectricTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21)
@ -32,7 +33,7 @@ public class SettingsImporterTest {
private void deletePreExistingAccounts() {
Preferences preferences = Preferences.getPreferences(RuntimeEnvironment.application);
for (Account account: preferences.getAccounts()) {
for (Account account : preferences.getAccounts()) {
preferences.deleteAccount(account);
}
}
@ -97,7 +98,7 @@ public class SettingsImporterTest {
public void parseSettings_account() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\""+validUUID+"\"><name>Account</name></account></accounts></k9settings>");
"<accounts><account uuid=\"" + validUUID + "\"><name>Account</name></account></accounts></k9settings>");
List<String> accountUuids = new ArrayList<>();
accountUuids.add("1");
@ -112,7 +113,7 @@ public class SettingsImporterTest {
public void parseSettings_account_identities() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\""+validUUID+"\"><name>Account</name>" +
"<accounts><account uuid=\"" + validUUID + "\"><name>Account</name>" +
"<identities><identity><email>user@gmail.com</email></identity></identities>" +
"</account></accounts></k9settings>");
List<String> accountUuids = new ArrayList<>();
@ -131,7 +132,7 @@ public class SettingsImporterTest {
public void parseSettings_account_cram_md5() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\""+validUUID+"\"><name>Account</name>" +
"<accounts><account uuid=\"" + validUUID + "\"><name>Account</name>" +
"<incoming-server><authentication-type>CRAM_MD5</authentication-type></incoming-server>" +
"</account></accounts></k9settings>");
List<String> accountUuids = new ArrayList<>();
@ -148,7 +149,7 @@ public class SettingsImporterTest {
public void importSettings_disablesAccountsNeedingPasswords() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\""+validUUID+"\"><name>Account</name>" +
"<accounts><account uuid=\"" + validUUID + "\"><name>Account</name>" +
"<incoming-server type=\"IMAP\">" +
"<connection-security>SSL_TLS_REQUIRED</connection-security>" +
"<username>user@gmail.com</username>" +
@ -183,9 +184,16 @@ public class SettingsImporterTest {
public void getImportStreamContents_account() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\""+validUUID+"\"><name>Account</name>" +
"<identities><identity><email>user@gmail.com</email></identity></identities>" +
"</account></accounts></k9settings>");
"<accounts>" +
"<account uuid=\"" + validUUID + "\">" +
"<name>Account</name>" +
"<identities>" +
"<identity>" +
"<email>user@gmail.com</email>" +
"</identity>" +
"</identities>" +
"</account>" +
"</accounts></k9settings>");
SettingsImporter.ImportContents results = SettingsImporter.getImportStreamContents(inputStream);
@ -199,9 +207,16 @@ public class SettingsImporterTest {
public void getImportStreamContents_alternativeName() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\""+validUUID+"\"><name></name>" +
"<identities><identity><email>user@gmail.com</email></identity></identities>" +
"</account></accounts></k9settings>");
"<accounts>" +
"<account uuid=\"" + validUUID + "\">" +
"<name></name>" +
"<identities>" +
"<identity>" +
"<email>user@gmail.com</email>" +
"</identity>" +
"</identities>" +
"</account>" +
"</accounts></k9settings>");
SettingsImporter.ImportContents results = SettingsImporter.getImportStreamContents(inputStream);