|
11 | 11 | import com.linkedin.metadata.dao.EbeanLocalRelationshipQueryDAO;
|
12 | 12 | import com.linkedin.metadata.dao.EbeanLocalRelationshipWriterDAO;
|
13 | 13 | import com.linkedin.metadata.dao.IEbeanLocalAccess;
|
| 14 | +import com.linkedin.metadata.dao.internal.BaseGraphWriterDAO; |
14 | 15 | import com.linkedin.metadata.dao.scsi.EmptyPathExtractor;
|
15 | 16 | import com.linkedin.metadata.dao.utils.EBeanDAOUtils;
|
16 | 17 | import com.linkedin.metadata.dao.utils.EmbeddedMariaInstance;
|
| 18 | +import com.linkedin.metadata.dao.utils.SQLSchemaUtils; |
| 19 | +import com.linkedin.metadata.dao.utils.SQLStatementUtils; |
17 | 20 | import com.linkedin.metadata.query.AspectField;
|
18 | 21 | import com.linkedin.metadata.query.Condition;
|
19 | 22 | import com.linkedin.metadata.query.LocalRelationshipCriterion;
|
|
38 | 41 | import com.linkedin.testing.urn.FooUrn;
|
39 | 42 | import io.ebean.Ebean;
|
40 | 43 | import io.ebean.EbeanServer;
|
| 44 | +import io.ebean.SqlUpdate; |
41 | 45 | import java.io.IOException;
|
42 | 46 | import java.net.URISyntaxException;
|
43 | 47 | import java.nio.charset.StandardCharsets;
|
@@ -156,6 +160,25 @@ public void testFindOneRelationship() throws Exception {
|
156 | 160 | Set<FooUrn> actual = reportsToAlice.stream().map(reportsTo -> makeFooUrn(reportsTo.getSource().toString())).collect(Collectors.toSet());
|
157 | 161 | Set<FooUrn> expected = ImmutableSet.of(jack, bob);
|
158 | 162 | assertEquals(actual, expected);
|
| 163 | + |
| 164 | + // Soft (set delete_ts = now()) Delete Jack reports-to ALice relationship |
| 165 | + SqlUpdate deletionSQL = _server.createSqlUpdate( |
| 166 | + SQLStatementUtils.deleteLocaRelationshipSQL(SQLSchemaUtils.getRelationshipTableName(jackReportsToAlice), |
| 167 | + BaseGraphWriterDAO.RemovalOption.REMOVE_ALL_EDGES_FROM_SOURCE)); |
| 168 | + deletionSQL.setParameter("source", jack.toString()); |
| 169 | + deletionSQL.execute(); |
| 170 | + |
| 171 | + reportsToAlice = _localRelationshipQueryDAO.findRelationships(FooSnapshot.class, |
| 172 | + new LocalRelationshipFilter().setCriteria(new LocalRelationshipCriterionArray()), FooSnapshot.class, filter, |
| 173 | + ReportsTo.class, new LocalRelationshipFilter().setCriteria(new LocalRelationshipCriterionArray()), 0, 10); |
| 174 | + |
| 175 | + // Expect: only bob reports to Alice |
| 176 | + assertEquals(reportsToAlice.size(), 1); |
| 177 | + actual = reportsToAlice.stream() |
| 178 | + .map(reportsTo -> makeFooUrn(reportsTo.getSource().toString())) |
| 179 | + .collect(Collectors.toSet()); |
| 180 | + expected = ImmutableSet.of(bob); |
| 181 | + assertEquals(actual, expected); |
159 | 182 | }
|
160 | 183 |
|
161 | 184 | @Test
|
|
0 commit comments