Skip to content

Commit a22d000

Browse files
committed
test(aspect migration mutator): Handled review comments.
1 parent 092cce7 commit a22d000

1 file changed

Lines changed: 15 additions & 24 deletions

File tree

entity-registry/src/test/java/com/linkedin/metadata/aspect/hooks/AspectMigrationMutatorBaseTest.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static org.mockito.Mockito.mock;
44
import static org.mockito.Mockito.when;
55
import static org.testng.Assert.assertEquals;
6-
import static org.testng.Assert.assertFalse;
76
import static org.testng.Assert.assertTrue;
87

98
import com.linkedin.common.urn.Urn;
@@ -30,9 +29,9 @@
3029
* and tests the happy path for both write and read mutations, so concrete mutator tests can focus
3130
* on supplying realistic aspect payloads and asserting the correctness of the transformed result.
3231
*
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:
3635
*
3736
* <ol>
3837
* <li><b>Required:</b> {@link #mutator()} — the implementation under test
@@ -107,8 +106,18 @@ public abstract class AspectMigrationMutatorBaseTest {
107106

108107
/**
109108
* 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>
112121
*/
113122
protected void configureRetrieverMock(@Nonnull AspectRetriever retrieverMock) {
114123
// no-op by default
@@ -184,24 +193,6 @@ public void writeMutation_atDefaultSchemaVersion_mutatesAndBumpsVersion() {
184193
assertTransformed(item.getRecordTemplate());
185194
}
186195

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-
205196
// Read path (auto-inherited)
206197
@Test
207198
public void readMutation_atSourceVersion_mutatesAndBumpsVersion() {

0 commit comments

Comments
 (0)