|
3 | 3 | import static org.mockito.Mockito.mock; |
4 | 4 | import static org.mockito.Mockito.when; |
5 | 5 | import static org.testng.Assert.assertEquals; |
6 | | -import static org.testng.Assert.assertFalse; |
7 | 6 | import static org.testng.Assert.assertTrue; |
8 | 7 |
|
9 | 8 | import com.linkedin.common.urn.Urn; |
|
30 | 29 | * and tests the happy path for both write and read mutations, so concrete mutator tests can focus |
31 | 30 | * on supplying realistic aspect payloads and asserting the correctness of the transformed result. |
32 | 31 | * |
33 | | - * <p>Extend this class for every concrete {@link AspectMigrationMutator} implementation. All |
34 | | - * contract-level {@code @Test} methods are inherited automatically. The subclass must implement |
35 | | - * four abstract methods and may optionally override one more: |
| 32 | + * <p>Extend this class for every concrete {@link AspectMigrationMutator} implementation. Three |
| 33 | + * transform-exercising {@code @Test} methods are inherited automatically; the subclass must |
| 34 | + * implement four abstract methods and may optionally override one more: |
36 | 35 | * |
37 | 36 | * <ol> |
38 | 37 | * <li><b>Required:</b> {@link #mutator()} — the implementation under test |
@@ -107,8 +106,18 @@ public abstract class AspectMigrationMutatorBaseTest { |
107 | 106 |
|
108 | 107 | /** |
109 | 108 | * Hook for subclasses to configure additional retriever mock behavior. Called at the end of |
110 | | - * {@link #setUp()} after the base stubs are in place. Override when the mutator under test uses |
111 | | - * the retriever to compute the transform (e.g. to look up related aspects). |
| 109 | + * {@link #setUp()} after the base stubs are in place. Override when the mutator under test calls |
| 110 | + * {@code context.getAspectRetriever()} during {@code transform()} to look up related aspects. |
| 111 | + * {@link #mockRetriever} is also accessible as a field for per-test stubs or {@code verify()} |
| 112 | + * calls. |
| 113 | + * |
| 114 | + * <pre>{@code |
| 115 | + * @Override |
| 116 | + * protected void configureRetrieverMock(AspectRetriever retrieverMock) { |
| 117 | + * when(retrieverMock.getLatestAspect(any(), eq("ownership"))) |
| 118 | + * .thenReturn(someAspect); |
| 119 | + * } |
| 120 | + * }</pre> |
112 | 121 | */ |
113 | 122 | protected void configureRetrieverMock(@Nonnull AspectRetriever retrieverMock) { |
114 | 123 | // no-op by default |
@@ -184,24 +193,6 @@ public void writeMutation_atDefaultSchemaVersion_mutatesAndBumpsVersion() { |
184 | 193 | assertTransformed(item.getRecordTemplate()); |
185 | 194 | } |
186 | 195 |
|
187 | | - @Test |
188 | | - public void writeMutation_futureVersion_isNoOp() { |
189 | | - SystemMetadata sm = new SystemMetadata(); |
190 | | - long futureVersion = mutator().getTargetVersion() + 1; |
191 | | - sm.setSchemaVersion(futureVersion); // ahead of this mutator |
192 | | - |
193 | | - ChangeMCP item = buildItem(provideSourceAspect(), sm); |
194 | | - |
195 | | - List<Pair<ChangeMCP, Boolean>> results = |
196 | | - mutator().writeMutation(List.of(item), retrieverContext).collect(Collectors.toList()); |
197 | | - |
198 | | - assertFalse(results.get(0).getSecond(), "Expected no-op for version ahead of targetVersion"); |
199 | | - assertEquals( |
200 | | - (long) item.getSystemMetadata().getSchemaVersion(), |
201 | | - futureVersion, |
202 | | - "schemaVersion must not be modified for a future version"); |
203 | | - } |
204 | | - |
205 | 196 | // Read path (auto-inherited) |
206 | 197 | @Test |
207 | 198 | public void readMutation_atSourceVersion_mutatesAndBumpsVersion() { |
|
0 commit comments