Skip to content

Commit fad1ed5

Browse files
authored
Fix and test register upload + api strategies
1 parent 0f456e8 commit fad1ed5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

cloudinary-core/src/main/java/com/cloudinary/Cloudinary.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@SuppressWarnings({"rawtypes", "unchecked"})
2121
public class Cloudinary {
2222

23-
private static List<String> UPLOAD_STRATEGIES = new ArrayList<String>(Arrays.asList(
23+
public static List<String> UPLOAD_STRATEGIES = new ArrayList<String>(Arrays.asList(
2424
"com.cloudinary.android.UploaderStrategy",
2525
"com.cloudinary.http5.UploaderStrategy"));
2626
public static List<String> API_STRATEGIES = new ArrayList<String>(Arrays.asList(
@@ -59,14 +59,14 @@ public SearchFolders searchFolders() {
5959

6060
public static void registerUploaderStrategy(String className) {
6161
if (!UPLOAD_STRATEGIES.contains(className)) {
62-
UPLOAD_STRATEGIES.add(className);
62+
UPLOAD_STRATEGIES.add(0, className);
6363
}
6464

6565
}
6666

6767
public static void registerAPIStrategy(String className) {
6868
if (!API_STRATEGIES.contains(className)) {
69-
API_STRATEGIES.add(className);
69+
API_STRATEGIES.add(0, className);
7070
}
7171
}
7272

cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,20 @@ public void testDownloadBackedupAsset() throws UnsupportedEncodingException, URI
14641464
assertNotNull(params.get("timestamp"));
14651465
}
14661466

1467+
@Test
1468+
public void testRegisterUploaderStrategy() {
1469+
String className = "myUploadStrategy";
1470+
Cloudinary.registerUploaderStrategy(className);
1471+
assertEquals(className, Cloudinary.UPLOAD_STRATEGIES.get(0));
1472+
}
1473+
1474+
@Test
1475+
public void testRegisterApiStrategy() {
1476+
String className = "myApiStrategy";
1477+
Cloudinary.registerAPIStrategy(className);
1478+
assertEquals(className, Cloudinary.API_STRATEGIES.get(0));
1479+
}
1480+
14671481
private void assertFieldsEqual(Object a, Object b) throws IllegalAccessException {
14681482
assertEquals("Two objects must be the same class", a.getClass(), b.getClass());
14691483
Field[] fields = a.getClass().getFields();

0 commit comments

Comments
 (0)