| 1 |
|
package org.europa.together.application; |
| 2 |
|
|
| 3 |
|
import static com.google.code.beanmatchers.BeanMatchers.*; |
| 4 |
|
import java.awt.image.BufferedImage; |
| 5 |
|
import java.io.File; |
| 6 |
|
import org.europa.together.JUnit5Preperator; |
| 7 |
|
import org.europa.together.business.ImageProcessor; |
| 8 |
|
import org.europa.together.business.Logger; |
| 9 |
|
import org.europa.together.domain.LogLevel; |
| 10 |
|
import org.europa.together.utils.Constraints; |
| 11 |
|
import static org.hamcrest.MatcherAssert.assertThat; |
| 12 |
|
import org.junit.jupiter.api.AfterAll; |
| 13 |
|
import org.junit.jupiter.api.AfterEach; |
| 14 |
|
import static org.junit.jupiter.api.Assertions.*; |
| 15 |
|
import org.junit.jupiter.api.Assumptions; |
| 16 |
|
import org.junit.jupiter.api.BeforeAll; |
| 17 |
|
import org.junit.jupiter.api.BeforeEach; |
| 18 |
|
import org.junit.jupiter.api.Test; |
| 19 |
|
import org.junit.jupiter.api.extension.ExtendWith; |
| 20 |
|
import org.springframework.beans.factory.annotation.Autowired; |
| 21 |
|
import org.springframework.test.context.ContextConfiguration; |
| 22 |
|
import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 23 |
|
|
| 24 |
|
@SuppressWarnings("unchecked") |
| 25 |
|
@ExtendWith({SpringExtension.class, JUnit5Preperator.class}) |
| 26 |
|
@ContextConfiguration(locations = {"/applicationContext.xml"}) |
| |
|
| 94.4% |
Uncovered Elements: 11 (195) |
Complexity: 44 |
Complexity Density: 0.27 |
|
| 27 |
|
public class ImgSclrProcessorTest { |
| 28 |
|
|
| 29 |
|
private static final Logger LOGGER = new LogbackLogger(ImgSclrProcessorTest.class); |
| 30 |
|
|
| 31 |
|
private static final String DIRECTORY |
| 32 |
|
= Constraints.SYSTEM_APP_DIR + "/target/test-classes/org/europa/together/images/"; |
| 33 |
|
|
| 34 |
|
@Autowired |
| 35 |
|
private ImageProcessor processor; |
| 36 |
|
|
| 37 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 38 |
1 |
@BeforeAll... |
| 39 |
|
static void setUp() { |
| 40 |
1 |
Assumptions.assumeTrue(true, "Assumtion failed."); |
| 41 |
|
|
| 42 |
1 |
LOGGER.log("Assumptions passed ...\n\n", LogLevel.DEBUG); |
| 43 |
|
} |
| 44 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 45 |
1 |
@AfterAll... |
| 46 |
|
static void tearDown() { |
| 47 |
|
} |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
29 |
@BeforeEach... |
| 50 |
|
void testCaseInitialization() { |
| 51 |
29 |
processor.clearImage(); |
| 52 |
|
} |
| 53 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 54 |
29 |
@AfterEach... |
| 55 |
|
void testCaseTermination() { |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 59 |
1 |
@Test... |
| 60 |
|
void constructor() { |
| 61 |
1 |
LOGGER.log("TEST CASE: constructor", LogLevel.DEBUG); |
| 62 |
|
|
| 63 |
1 |
assertThat(ImgSclrProcessor.class, hasValidBeanConstructor()); |
| 64 |
|
} |
| 65 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 66 |
1 |
@Test... |
| 67 |
|
void loadImageAsFile() { |
| 68 |
1 |
LOGGER.log("TEST CASE: loadImageAsFile", LogLevel.DEBUG); |
| 69 |
|
|
| 70 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 71 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 72 |
|
} |
| 73 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 74 |
1 |
@Test... |
| 75 |
|
void loadImageAsBufferedImage() { |
| 76 |
1 |
LOGGER.log("TEST CASE: loadImageAsBufferedImage", LogLevel.DEBUG); |
| 77 |
|
|
| 78 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 79 |
1 |
BufferedImage img = processor.getImage(); |
| 80 |
1 |
assertNotNull(img); |
| 81 |
1 |
assertTrue(processor.loadImage(img)); |
| 82 |
|
} |
| 83 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 84 |
1 |
@Test... |
| 85 |
|
void failLoadImage() { |
| 86 |
1 |
LOGGER.log("TEST CASE: failLoadImage", LogLevel.DEBUG); |
| 87 |
|
|
| 88 |
1 |
assertFalse(processor.loadImage(new File(DIRECTORY + "No_Image.gif"))); |
| 89 |
1 |
BufferedImage img = null; |
| 90 |
1 |
assertFalse(processor.loadImage(img)); |
| 91 |
|
} |
| 92 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 93 |
1 |
@Test... |
| 94 |
|
void saveImageAsJpg() { |
| 95 |
1 |
LOGGER.log("TEST CASE: saveImageAsJpg", LogLevel.DEBUG); |
| 96 |
|
|
| 97 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 98 |
1 |
BufferedImage img = processor.getImage(); |
| 99 |
1 |
try { |
| 100 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_save.jpg"), |
| 101 |
|
ImageProcessor.FORMAT_JPG)); |
| 102 |
|
} catch (Exception ex) { |
| 103 |
0 |
LOGGER.catchException(ex); |
| 104 |
|
} |
| 105 |
|
} |
| 106 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 107 |
1 |
@Test... |
| 108 |
|
void saveImageAsJpeg() { |
| 109 |
1 |
LOGGER.log("TEST CASE: saveImageAsJpeg", LogLevel.DEBUG); |
| 110 |
|
|
| 111 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 112 |
1 |
BufferedImage img = processor.getImage(); |
| 113 |
1 |
try { |
| 114 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_save.jpeg"), |
| 115 |
|
ImageProcessor.FORMAT_JPEG)); |
| 116 |
|
} catch (Exception ex) { |
| 117 |
0 |
LOGGER.catchException(ex); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 121 |
1 |
@Test... |
| 122 |
|
void saveImageAsGif() { |
| 123 |
1 |
LOGGER.log("TEST CASE: saveImageAsGif", LogLevel.DEBUG); |
| 124 |
|
|
| 125 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 126 |
1 |
BufferedImage img = processor.getImage(); |
| 127 |
1 |
try { |
| 128 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_save.gif"), |
| 129 |
|
ImageProcessor.FORMAT_GIF)); |
| 130 |
|
} catch (Exception ex) { |
| 131 |
0 |
LOGGER.catchException(ex); |
| 132 |
|
} |
| 133 |
|
} |
| 134 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
| 135 |
1 |
@Test... |
| 136 |
|
void saveImageAsPng() { |
| 137 |
1 |
LOGGER.log("TEST CASE: saveImageAsPng", LogLevel.DEBUG); |
| 138 |
|
|
| 139 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 140 |
1 |
BufferedImage img = processor.getImage(); |
| 141 |
1 |
try { |
| 142 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_save.png"), |
| 143 |
|
ImageProcessor.FORMAT_PNG)); |
| 144 |
|
} catch (Exception ex) { |
| 145 |
0 |
LOGGER.catchException(ex); |
| 146 |
|
} |
| 147 |
|
} |
| 148 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 149 |
1 |
@Test... |
| 150 |
|
void saveImageWrongType() throws Exception { |
| 151 |
1 |
LOGGER.log("TEST CASE: saveImageWrongType", LogLevel.DEBUG); |
| 152 |
|
|
| 153 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 154 |
1 |
BufferedImage img = processor.getImage(); |
| 155 |
|
|
| 156 |
1 |
assertThrows(Exception.class, () -> { |
| 157 |
1 |
processor.saveImage(img, new File(DIRECTORY + "image_fail_safe.png"), "bpm"); |
| 158 |
|
}); |
| 159 |
|
} |
| 160 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 161 |
1 |
@Test... |
| 162 |
|
void failSaveImage() throws Exception { |
| 163 |
1 |
LOGGER.log("TEST CASE: failSaveImage", LogLevel.DEBUG); |
| 164 |
|
|
| 165 |
1 |
assertFalse(processor.saveImage(null, null, "jpg")); |
| 166 |
|
} |
| 167 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 168 |
1 |
@Test... |
| 169 |
|
void imageDimensions() { |
| 170 |
1 |
LOGGER.log("TEST CASE: imageDimensions", LogLevel.DEBUG); |
| 171 |
|
|
| 172 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 173 |
1 |
assertEquals(407, processor.getHeight()); |
| 174 |
1 |
assertEquals(226, processor.getWidth()); |
| 175 |
|
} |
| 176 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 177 |
1 |
@Test... |
| 178 |
|
void calculateImageSize() { |
| 179 |
1 |
LOGGER.log("TEST CASE: calculateImageSize", LogLevel.DEBUG); |
| 180 |
|
|
| 181 |
1 |
assertEquals(0, processor.getImageSize(null)); |
| 182 |
|
} |
| 183 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 184 |
1 |
@Test... |
| 185 |
|
void failCalculateImageSize() { |
| 186 |
1 |
LOGGER.log("TEST CASE: failCalculateImageSize", LogLevel.DEBUG); |
| 187 |
|
|
| 188 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 189 |
1 |
BufferedImage img = processor.getImage(); |
| 190 |
1 |
assertEquals(367928, processor.getImageSize(img)); |
| 191 |
|
} |
| 192 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 193 |
1 |
@Test... |
| 194 |
|
void reset() { |
| 195 |
1 |
LOGGER.log("TEST CASE: reset", LogLevel.DEBUG); |
| 196 |
|
|
| 197 |
1 |
assertFalse(processor.isImageSet()); |
| 198 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 199 |
1 |
assertTrue(processor.isImageSet()); |
| 200 |
1 |
processor.clearImage(); |
| 201 |
1 |
assertFalse(processor.isImageSet()); |
| 202 |
|
} |
| 203 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
1PASS
|
|
| 204 |
1 |
@Test... |
| 205 |
|
void resizeImageReduce() { |
| 206 |
1 |
LOGGER.log("TEST CASE: resizeImageReduce", LogLevel.DEBUG); |
| 207 |
|
|
| 208 |
1 |
try { |
| 209 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 210 |
1 |
assertTrue(processor.isImageSet()); |
| 211 |
1 |
BufferedImage img = processor.resize(50); |
| 212 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_resize_reduce.png"), ImageProcessor.FORMAT_PNG)); |
| 213 |
|
|
| 214 |
1 |
processor.clearImage(); |
| 215 |
1 |
processor.loadImage(new File(DIRECTORY + "image_resize_reduce.png")); |
| 216 |
1 |
assertEquals(203, processor.getHeight()); |
| 217 |
1 |
assertEquals(113, processor.getWidth()); |
| 218 |
|
|
| 219 |
|
} catch (Exception ex) { |
| 220 |
0 |
LOGGER.catchException(ex); |
| 221 |
|
} |
| 222 |
|
} |
| 223 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
1PASS
|
|
| 224 |
1 |
@Test... |
| 225 |
|
void resizeImageNoEffect() { |
| 226 |
1 |
LOGGER.log("TEST CASE: resizeImageNoEffect", LogLevel.DEBUG); |
| 227 |
|
|
| 228 |
1 |
try { |
| 229 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 230 |
1 |
assertTrue(processor.isImageSet()); |
| 231 |
1 |
BufferedImage img = processor.resize(100); |
| 232 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_resize_noEffect.png"), ImageProcessor.FORMAT_PNG)); |
| 233 |
|
|
| 234 |
1 |
processor.clearImage(); |
| 235 |
1 |
processor.loadImage(new File(DIRECTORY + "image_resize_noEffect.png")); |
| 236 |
1 |
assertEquals(407, processor.getHeight()); |
| 237 |
1 |
assertEquals(226, processor.getWidth()); |
| 238 |
|
|
| 239 |
|
} catch (Exception ex) { |
| 240 |
0 |
LOGGER.catchException(ex); |
| 241 |
|
} |
| 242 |
|
} |
| 243 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
1PASS
|
|
| 244 |
1 |
@Test... |
| 245 |
|
void resizeImageInflate() { |
| 246 |
1 |
LOGGER.log("TEST CASE: resizeImageInflate", LogLevel.DEBUG); |
| 247 |
|
|
| 248 |
1 |
try { |
| 249 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 250 |
1 |
assertTrue(processor.isImageSet()); |
| 251 |
1 |
BufferedImage img = processor.resize(150); |
| 252 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_resize_inflate.png"), ImageProcessor.FORMAT_PNG)); |
| 253 |
|
|
| 254 |
1 |
processor.clearImage(); |
| 255 |
1 |
processor.loadImage(new File(DIRECTORY + "image_resize_inflate.png")); |
| 256 |
1 |
assertEquals(610, processor.getHeight()); |
| 257 |
1 |
assertEquals(339, processor.getWidth()); |
| 258 |
|
|
| 259 |
|
} catch (Exception ex) { |
| 260 |
0 |
LOGGER.catchException(ex); |
| 261 |
|
} |
| 262 |
|
} |
| 263 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 264 |
1 |
@Test... |
| 265 |
|
void failResize() throws Exception { |
| 266 |
1 |
LOGGER.log("TEST CASE: failResize", LogLevel.DEBUG); |
| 267 |
|
|
| 268 |
1 |
assertThrows(Exception.class, () -> { |
| 269 |
1 |
processor.resize(50); |
| 270 |
|
}); |
| 271 |
|
} |
| 272 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 273 |
1 |
@Test... |
| 274 |
|
void failResizeImage() throws Exception { |
| 275 |
1 |
LOGGER.log("TEST CASE: failResizeImage", LogLevel.DEBUG); |
| 276 |
|
|
| 277 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 278 |
1 |
assertTrue(processor.isImageSet()); |
| 279 |
|
|
| 280 |
1 |
assertThrows(Exception.class, () -> { |
| 281 |
1 |
BufferedImage img = processor.resize(0); |
| 282 |
|
}); |
| 283 |
|
} |
| 284 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
1PASS
|
|
| 285 |
1 |
@Test... |
| 286 |
|
void imageRotate() { |
| 287 |
1 |
LOGGER.log("TEST CASE: imageRotate", LogLevel.DEBUG); |
| 288 |
|
|
| 289 |
1 |
try { |
| 290 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 291 |
1 |
assertTrue(processor.isImageSet()); |
| 292 |
1 |
BufferedImage img = processor.rotateRight(); |
| 293 |
|
|
| 294 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_rotate.png"), ImageProcessor.FORMAT_PNG)); |
| 295 |
|
|
| 296 |
1 |
processor.clearImage(); |
| 297 |
1 |
processor.loadImage(new File(DIRECTORY + "image_rotate.png")); |
| 298 |
1 |
assertEquals(226, processor.getHeight()); |
| 299 |
1 |
assertEquals(407, processor.getWidth()); |
| 300 |
|
|
| 301 |
|
} catch (Exception ex) { |
| 302 |
0 |
LOGGER.catchException(ex); |
| 303 |
|
} |
| 304 |
|
} |
| 305 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 306 |
1 |
@Test... |
| 307 |
|
void failImageRotate() throws Exception { |
| 308 |
1 |
LOGGER.log("TEST CASE: failImageRotate", LogLevel.DEBUG); |
| 309 |
|
|
| 310 |
1 |
assertThrows(Exception.class, () -> { |
| 311 |
1 |
processor.rotateRight(); |
| 312 |
|
}); |
| 313 |
|
} |
| 314 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
1PASS
|
|
| 315 |
1 |
@Test... |
| 316 |
|
void imageFlipVertical() { |
| 317 |
1 |
LOGGER.log("TEST CASE: imageFlipVertical", LogLevel.DEBUG); |
| 318 |
|
|
| 319 |
1 |
try { |
| 320 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 321 |
1 |
assertTrue(processor.isImageSet()); |
| 322 |
1 |
BufferedImage img = processor.flipVertical(); |
| 323 |
|
|
| 324 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_flip_vertical.png"), ImageProcessor.FORMAT_PNG)); |
| 325 |
|
|
| 326 |
|
} catch (Exception ex) { |
| 327 |
0 |
LOGGER.catchException(ex); |
| 328 |
|
} |
| 329 |
|
} |
| 330 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 331 |
1 |
@Test... |
| 332 |
|
void failFlipVertical() throws Exception { |
| 333 |
1 |
LOGGER.log("TEST CASE: failFlipVertical", LogLevel.DEBUG); |
| 334 |
|
|
| 335 |
1 |
assertThrows(Exception.class, () -> { |
| 336 |
1 |
processor.flipVertical(); |
| 337 |
|
}); |
| 338 |
|
} |
| 339 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
1PASS
|
|
| 340 |
1 |
@Test... |
| 341 |
|
void imageFlipHorizontal() { |
| 342 |
1 |
LOGGER.log("TEST CASE: imageFlipHorizontal", LogLevel.DEBUG); |
| 343 |
|
|
| 344 |
1 |
try { |
| 345 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 346 |
1 |
assertTrue(processor.isImageSet()); |
| 347 |
1 |
BufferedImage img = processor.flipHorizontal(); |
| 348 |
|
|
| 349 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_flip_horizontal.png"), ImageProcessor.FORMAT_PNG)); |
| 350 |
|
|
| 351 |
|
} catch (Exception ex) { |
| 352 |
0 |
LOGGER.catchException(ex); |
| 353 |
|
} |
| 354 |
|
} |
| 355 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 356 |
1 |
@Test... |
| 357 |
|
void failFlipHorizontal() throws Exception { |
| 358 |
1 |
LOGGER.log("TEST CASE: failFlipHorizontal", LogLevel.DEBUG); |
| 359 |
|
|
| 360 |
1 |
assertThrows(Exception.class, () -> { |
| 361 |
1 |
processor.flipHorizontal(); |
| 362 |
|
}); |
| 363 |
|
} |
| 364 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
1PASS
|
|
| 365 |
1 |
@Test... |
| 366 |
|
void cropImage() { |
| 367 |
1 |
LOGGER.log("TEST CASE: cropImage", LogLevel.DEBUG); |
| 368 |
|
|
| 369 |
1 |
try { |
| 370 |
1 |
processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png")); |
| 371 |
1 |
assertTrue(processor.isImageSet()); |
| 372 |
1 |
BufferedImage img = processor.crop(30, 50, 150, 100); |
| 373 |
|
|
| 374 |
1 |
assertTrue(processor.saveImage(img, new File(DIRECTORY + "image_cropped.png"), ImageProcessor.FORMAT_PNG)); |
| 375 |
|
|
| 376 |
1 |
processor.clearImage(); |
| 377 |
1 |
processor.loadImage(new File(DIRECTORY + "image_cropped.png")); |
| 378 |
1 |
assertEquals(150, processor.getHeight()); |
| 379 |
1 |
assertEquals(100, processor.getWidth()); |
| 380 |
|
} catch (Exception ex) { |
| 381 |
0 |
LOGGER.catchException(ex); |
| 382 |
|
} |
| 383 |
|
|
| 384 |
|
} |
| 385 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 386 |
1 |
@Test... |
| 387 |
|
void failCropImage() throws Exception { |
| 388 |
1 |
LOGGER.log("TEST CASE: failCropImage", LogLevel.DEBUG); |
| 389 |
|
|
| 390 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 391 |
1 |
assertThrows(Exception.class, () -> { |
| 392 |
1 |
processor.crop(0, 0, 0, 0); |
| 393 |
|
}); |
| 394 |
|
} |
| 395 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 396 |
1 |
@Test... |
| 397 |
|
void generateToString() { |
| 398 |
1 |
LOGGER.log("TEST CASE: generateToString", LogLevel.DEBUG); |
| 399 |
|
|
| 400 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "135621.jpg"))); |
| 401 |
1 |
LOGGER.log("toString: " + processor.toString(), LogLevel.DEBUG); |
| 402 |
1 |
assertNotEquals("No meta data from 135621.jpg extracted.", processor.toString()); |
| 403 |
|
} |
| 404 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 405 |
1 |
@Test... |
| 406 |
|
void generateToStringWhitoutMetaData() { |
| 407 |
1 |
LOGGER.log("TEST CASE: generateToStringWhitoutMetaData", LogLevel.DEBUG); |
| 408 |
|
|
| 409 |
1 |
assertTrue(processor.loadImage(new File(DIRECTORY + "duke_java_mascot.png"))); |
| 410 |
1 |
LOGGER.log("toString: " + processor.toString(), LogLevel.DEBUG); |
| 411 |
1 |
assertEquals("No meta data from duke_java_mascot.png extracted.", processor.toString()); |
| 412 |
|
} |
| 413 |
|
} |