Skip to content

Commit 8c482a9

Browse files
author
Amir Tocker
committed
Define MockableTest
1 parent 3d78528 commit 8c482a9

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractApiTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import static org.junit.Assume.assumeNotNull;
2424

2525
@SuppressWarnings({"rawtypes", "unchecked", "JavaDoc"})
26-
abstract public class AbstractApiTest {
27-
26+
abstract public class AbstractApiTest extends MockableTest {
2827
private static final String SRC_TEST_IMAGE = "../cloudinary-test-common/src/main/resources/old_logo.png";
2928
private static final int SUFFIX = new Random().nextInt(99999);
3029
private static final String API_TEST = "api_test_" + SUFFIX;
@@ -122,14 +121,15 @@ public Map findByAttr(List<Map> elements, String attr, Object value) {
122121
public void test01ResourceTypes() throws Exception {
123122
// should allow listing resource_types
124123
Map result = api.resourceTypes(ObjectUtils.emptyMap());
125-
assertThat( (Collection) result.get("resource_types"), hasItem("image"));
124+
final List<String> resource_types = (List<String>) result.get("resource_types");
125+
assertThat(resource_types, hasItem("image"));
126126
}
127127

128128
@Test
129129
public void test02Resources() throws Exception {
130130
// should allow listing resources
131131
Map result = api.resources(ObjectUtils.emptyMap());
132-
final List resources = (List<Map<? extends String, ?>>) result.get("resources");
132+
final List<Map> resources = (List) result.get("resources");
133133
assertThat(resources, hasItem(allOf(hasEntry("public_id", API_TEST),hasEntry("type", "upload"))));
134134
}
135135

@@ -139,7 +139,7 @@ public void testTimeoutParameter() throws Exception {
139139
Map<String, Object> options = new HashMap<String, Object>();
140140
options.put("timeout", Integer.valueOf(5000));
141141
Map result = api.resources(options);
142-
List resources = (List<Map<? extends String, ?>>) result.get("resources");
142+
List<Map> resources = (List) result.get("resources");
143143
assertThat(resources, hasItem(allOf(hasEntry("public_id", API_TEST),hasEntry("type", "upload"))));
144144
}
145145

@@ -166,15 +166,15 @@ public void test03ResourcesCursor() throws Exception {
166166
public void test04ResourcesByType() throws Exception {
167167
// should allow listing resources by type
168168
Map result = api.resources(ObjectUtils.asMap("type", "upload"));
169-
List resources = (List<Map<? extends String, ?>>) result.get("resources");
169+
List<Map> resources = (List) result.get("resources");
170170
assertThat(resources, hasItem(hasEntry("public_id", API_TEST)));
171171
}
172172

173173
@Test
174174
public void test05ResourcesByPrefix() throws Exception {
175175
// should allow listing resources by prefix
176176
Map result = api.resources(ObjectUtils.asMap("type", "upload", "prefix", API_TEST, "tags", true, "context", true));
177-
List resources = (List<Map<? extends String, ?>>) result.get("resources");
177+
List<Map> resources = (List) result.get("resources");
178178
System.out.println(resources);
179179
assertThat(resources, hasItem(hasEntry("public_id", (Object) API_TEST)));
180180
assertThat(resources, hasItem(hasEntry("public_id", (Object) API_TEST_1)));
@@ -589,7 +589,7 @@ public void testUpdateUploadPreset() throws Exception {
589589
@Test
590590
public void testListByModerationUpdate() throws Exception {
591591
// "should support listing by moderation kind and value
592-
List resources;
592+
List<Map> resources;
593593

594594
Map result1 = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("moderation", "manual", "tags", SDK_TEST_TAG));
595595
Map result2 = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("moderation", "manual", "tags", SDK_TEST_TAG));
@@ -600,17 +600,17 @@ public void testListByModerationUpdate() throws Exception {
600600
Map rejected = api.resourcesByModeration("manual", "rejected", ObjectUtils.asMap("max_results", 1000));
601601
Map pending = api.resourcesByModeration("manual", "pending", ObjectUtils.asMap("max_results", 1000));
602602

603-
resources = (List<Map<? extends String, ?>>) approved.get("resources");
603+
resources = (List<Map>) approved.get("resources");
604604
assertThat(resources, hasItem(hasEntry("public_id", result1.get("public_id"))));
605605
assertThat(resources, not(hasItem(hasEntry("public_id", result2.get("public_id")))));
606606
assertThat(resources, not(hasItem(hasEntry("public_id", result3.get("public_id")))));
607607

608-
resources = (List<Map<? extends String, ?>>) rejected.get("resources");
608+
resources = (List<Map>) rejected.get("resources");
609609
assertThat(resources, not(hasItem(hasEntry("public_id", result1.get("public_id")))));
610610
assertThat(resources, hasItem(hasEntry("public_id", result2.get("public_id"))));
611611
assertThat(resources, not(hasItem(hasEntry("public_id", result3.get("public_id")))));
612612

613-
resources = (List<Map<? extends String, ?>>) pending.get("resources");
613+
resources = (List<Map>) pending.get("resources");
614614
assertThat(resources, not(hasItem(hasEntry("public_id", result1.get("public_id")))));
615615
assertThat(resources, not(hasItem(hasEntry("public_id", result2.get("public_id")))));
616616
assertThat(resources, hasItem(hasEntry("public_id", result3.get("public_id"))));
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.cloudinary.test;
2+
3+
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
4+
5+
/**
6+
* Created by amir on 01/08/2016.
7+
*/
8+
public class MockableTest {
9+
10+
protected Object getParam(String name){
11+
throw new NotImplementedException();
12+
};
13+
protected String getURL(){
14+
throw new NotImplementedException();
15+
};
16+
protected String getHttpMethod(){
17+
throw new NotImplementedException();
18+
};
19+
}

0 commit comments

Comments
 (0)