|
| 1 | +package com.applitools.imagetester.BatchMapper; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | +import static org.junit.Assert.*; |
| 5 | + |
| 6 | +// NOTE: setLayoutRegions(), setIgnoreRegions(), and setContentRegions() are no-arg |
| 7 | +// setters — they do not accept a value parameter. Calling them does not update the |
| 8 | +// field. Round-trip tests for those three fields therefore verify that the field |
| 9 | +// remains null after calling the broken setter, reflecting actual behavior. |
| 10 | +// See FIXME in BatchMapPojo: setters should accept a String parameter. |
| 11 | +public class BatchMapPojoTest { |
| 12 | + |
| 13 | + @Test |
| 14 | + public void getterSetterRoundTrip_filePath() { |
| 15 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 16 | + pojo.setFilePath("/path/to/file.pdf"); |
| 17 | + assertEquals("/path/to/file.pdf", pojo.getFilePath()); |
| 18 | + } |
| 19 | + |
| 20 | + @Test |
| 21 | + public void getterSetterRoundTrip_testName() { |
| 22 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 23 | + pojo.setTestName("My Test"); |
| 24 | + assertEquals("My Test", pojo.getTestName()); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void getterSetterRoundTrip_app() { |
| 29 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 30 | + pojo.setApp("MyApp"); |
| 31 | + assertEquals("MyApp", pojo.getApp()); |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + public void getterSetterRoundTrip_os() { |
| 36 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 37 | + pojo.setOs("Windows"); |
| 38 | + assertEquals("Windows", pojo.getOs()); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void getterSetterRoundTrip_browser() { |
| 43 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 44 | + pojo.setBrowser("Chrome"); |
| 45 | + assertEquals("Chrome", pojo.getBrowser()); |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + public void getterSetterRoundTrip_viewport() { |
| 50 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 51 | + pojo.setViewport("1024x768"); |
| 52 | + assertEquals("1024x768", pojo.getViewport()); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void getterSetterRoundTrip_matchsize() { |
| 57 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 58 | + pojo.setMatchsize("1000x"); |
| 59 | + assertEquals("1000x", pojo.getMatchsize()); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + public void getterSetterRoundTrip_pages() { |
| 64 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 65 | + pojo.setPages("1-5"); |
| 66 | + assertEquals("1-5", pojo.getPages()); |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + public void getterSetterRoundTrip_matchLevel() { |
| 71 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 72 | + pojo.setMatchLevel("Strict"); |
| 73 | + assertEquals("Strict", pojo.getMatchLevel()); |
| 74 | + } |
| 75 | + |
| 76 | + // CONCERN: setLayoutRegions() is a no-arg setter — it ignores its caller's value |
| 77 | + // and leaves the field null. The field can only be set by direct assignment or |
| 78 | + // via Jackson's public-field access. The test below documents actual behavior. |
| 79 | + @Test |
| 80 | + public void setter_layoutRegions_isNoArgAndLeavesFieldNull() { |
| 81 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 82 | + pojo.setLayoutRegions(); |
| 83 | + assertNull(pojo.getLayoutRegions()); |
| 84 | + } |
| 85 | + |
| 86 | + // CONCERN: same broken no-arg setter for ignoreRegions. |
| 87 | + @Test |
| 88 | + public void setter_ignoreRegions_isNoArgAndLeavesFieldNull() { |
| 89 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 90 | + pojo.setIgnoreRegions(); |
| 91 | + assertNull(pojo.getIgnoreRegions()); |
| 92 | + } |
| 93 | + |
| 94 | + // CONCERN: same broken no-arg setter for contentRegions. |
| 95 | + @Test |
| 96 | + public void setter_contentRegions_isNoArgAndLeavesFieldNull() { |
| 97 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 98 | + pojo.setContentRegions(); |
| 99 | + assertNull(pojo.getContentRegions()); |
| 100 | + } |
| 101 | + |
| 102 | + @Test |
| 103 | + public void equals_sameValues_returnsTrue() { |
| 104 | + BatchMapPojo a = createPojo("path", "test", "app"); |
| 105 | + BatchMapPojo b = createPojo("path", "test", "app"); |
| 106 | + assertEquals(a, b); |
| 107 | + } |
| 108 | + |
| 109 | + @Test |
| 110 | + public void equals_differentValues_returnsFalse() { |
| 111 | + BatchMapPojo a = createPojo("path1", "test", "app"); |
| 112 | + BatchMapPojo b = createPojo("path2", "test", "app"); |
| 113 | + assertNotEquals(a, b); |
| 114 | + } |
| 115 | + |
| 116 | + @Test |
| 117 | + public void equals_null_returnsFalse() { |
| 118 | + BatchMapPojo a = createPojo("path", "test", "app"); |
| 119 | + assertNotEquals(a, null); |
| 120 | + } |
| 121 | + |
| 122 | + // NOTE: toString() only includes filePath, testName, app, os, browser, viewport, |
| 123 | + // matchsize, pages, and matchLevel — not layoutRegions, contentRegions, or ignoreRegions. |
| 124 | + @Test |
| 125 | + public void toString_containsFieldValues() { |
| 126 | + BatchMapPojo pojo = createPojo("/my/path", "MyTest", "MyApp"); |
| 127 | + String str = pojo.toString(); |
| 128 | + assertTrue(str.contains("/my/path")); |
| 129 | + assertTrue(str.contains("MyTest")); |
| 130 | + assertTrue(str.contains("MyApp")); |
| 131 | + } |
| 132 | + |
| 133 | + private BatchMapPojo createPojo(String path, String testName, String app) { |
| 134 | + BatchMapPojo pojo = new BatchMapPojo(); |
| 135 | + pojo.setFilePath(path); |
| 136 | + pojo.setTestName(testName); |
| 137 | + pojo.setApp(app); |
| 138 | + return pojo; |
| 139 | + } |
| 140 | +} |
0 commit comments