Skip to content

Commit 7d394c1

Browse files
nitzanjAmir Tocker
authored andcommitted
Cleanup logs and improve exception handling for StreamingProfile tests.
1 parent 74b6c09 commit 7d394c1

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.cloudinary.Transformation;
66
import com.cloudinary.api.ApiResponse;
77
import com.cloudinary.api.exceptions.AlreadyExists;
8+
import com.cloudinary.api.exceptions.NotFound;
89
import com.cloudinary.utils.ObjectUtils;
910
import org.hamcrest.Matcher;
1011
import org.hamcrest.Matchers;
@@ -113,7 +114,7 @@ public void testUpdate() throws Exception {
113114
assertThat(profile, (Matcher) hasEntry("name", (Object) UPDATE_PROFILE_NAME));
114115
assertThat(profile, Matchers.hasEntry(equalTo("representations"), (Matcher) hasItem(hasKey("transformation"))));
115116
final Map representation = (Map) ((List) profile.get("representations")).get(0);
116-
Map transformation = (Map) ((List)representation.get("transformation")).get(0);
117+
Map transformation = (Map) ((List) representation.get("transformation")).get(0);
117118
assertThat(transformation, allOf(
118119
(Matcher) hasEntry("width", 800),
119120
(Matcher) hasEntry("height", 800),
@@ -123,14 +124,22 @@ public void testUpdate() throws Exception {
123124
}
124125

125126
@AfterClass
126-
public static void tearDownClass() {
127+
public static void tearDownClass() throws Exception {
127128
Api api = new Cloudinary().api();
128129
try {
129130
api.deleteStreamingProfile(CREATE_PROFILE_NAME);
130-
api.deleteStreamingProfile(DELETE_PROFILE_NAME);
131+
} catch (NotFound ignored) {
132+
}
133+
134+
try {
131135
api.deleteStreamingProfile(UPDATE_PROFILE_NAME);
132-
} catch (Exception e) {
133-
e.printStackTrace();
136+
} catch (NotFound ignored) {
137+
}
138+
139+
try {
140+
// this should already be gone but in case that deletion-test failed we still need to cleanup the account.
141+
api.deleteStreamingProfile(DELETE_PROFILE_NAME);
142+
} catch (NotFound ignored) {
134143
}
135144
}
136145
}

0 commit comments

Comments
 (0)