Explorar o código

codacy: assertTrue -> assertFalse
use specific exceptions
add missing break

tobiasKaminsky %!s(int64=7) %!d(string=hai) anos
pai
achega
58b7f33a48

+ 3 - 4
src/androidTest/java/com/owncloud/android/util/EncryptionTestIT.java

@@ -51,14 +51,13 @@ import java.util.HashSet;
 import java.util.Set;
 
 import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 
 @RequiresApi(api = Build.VERSION_CODES.KITKAT)
 @RunWith(AndroidJUnit4.class)
 public class EncryptionTestIT {
-    private static String TAG = EncryptionTestIT.class.getSimpleName();
-
     private String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAo" +
             "IBAQDsn0JKS/THu328z1IgN0VzYU53HjSX03WJIgWkmyTaxbiKpoJaKbksXmfSpgzV" +
             "GzKFvGfZ03fwFrN7Q8P8R2e8SNiell7mh1TDw9/0P7Bt/ER8PJrXORo+GviKHxaLr7" +
@@ -154,8 +153,8 @@ public class EncryptionTestIT {
         keyGen.initialize(2048, new SecureRandom());
         KeyPair keyPair = keyGen.generateKeyPair();
 
-        assertTrue(!CsrHelper.generateCsrPemEncodedString(keyPair).isEmpty());
-        assertTrue(!EncryptionUtils.encodeBytesToBase64String(keyPair.getPublic().getEncoded()).isEmpty());
+        assertFalse(CsrHelper.generateCsrPemEncodedString(keyPair).isEmpty());
+        assertFalse(EncryptionUtils.encodeBytesToBase64String(keyPair.getPublic().getEncoded()).isEmpty());
     }
 
     /**

+ 4 - 4
src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java

@@ -99,9 +99,9 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
             if (lockFileOperationResult.isSuccess()) {
                 token = (String) lockFileOperationResult.getData().get(0);
             } else if (lockFileOperationResult.getHttpCode() == HttpStatus.SC_FORBIDDEN) {
-                throw new RuntimeException("Forbidden! Please try again later.)");
+                throw new RemoteOperationFailedException("Forbidden! Please try again later.)");
             } else {
-                throw new RuntimeException("Unknown error!");
+                throw new RemoteOperationFailedException("Unknown error!");
             }
 
             // refresh metadata
@@ -118,7 +118,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
 
                 metadata = EncryptionUtils.decryptFolderMetaData(encryptedFolderMetadata, privateKey);
             } else {
-                throw new RuntimeException("No Metadata found!");
+                throw new RemoteOperationFailedException("No Metadata found!");
             }
 
             // delete file remote
@@ -142,7 +142,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
             RemoteOperationResult uploadMetadataOperationResult = storeMetadataOperation.execute(client);
 
             if (!uploadMetadataOperationResult.isSuccess()) {
-                throw new RuntimeException();
+                throw new RemoteOperationFailedException("Metadata not uploaded!");
             }
 
             // return success

+ 1 - 0
src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java

@@ -193,6 +193,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
 
                             default:
                                 dialog.dismiss();
+                                break;
                         }
                     }
                 });