DATAJDBC-207 - Polishing.
Formatting.
This commit is contained in:
committed by
Greg Turnquist
parent
b4b6625d50
commit
6bf916b9c4
@@ -95,11 +95,11 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
|
||||
String sql = sqlGenerator.createDeleteByPath(PropertyPath.from("ref.further", DummyEntity.class));
|
||||
|
||||
assertThat(sql).isEqualTo(
|
||||
"DELETE FROM " + user + ".second_level_referenced_entity " +
|
||||
"WHERE " + user + ".referenced_entity IN " +
|
||||
"(SELECT l1id FROM " + user + ".referenced_entity " +
|
||||
"WHERE " + user + ".dummy_entity = :rootId)");
|
||||
assertThat(sql).isEqualTo( //
|
||||
"DELETE FROM " + user + ".second_level_referenced_entity " //
|
||||
+ "WHERE " + user + ".referenced_entity IN " //
|
||||
+ "(SELECT l1id FROM " + user + ".referenced_entity " //
|
||||
+ "WHERE " + user + ".dummy_entity = :rootId)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
|
||||
String sql = sqlGenerator.createDeleteAllSql(PropertyPath.from("ref", DummyEntity.class));
|
||||
|
||||
assertThat(sql).isEqualTo(
|
||||
"DELETE FROM " + user + ".referenced_entity WHERE " + user + ".dummy_entity IS NOT NULL");
|
||||
assertThat(sql).isEqualTo( //
|
||||
"DELETE FROM " + user + ".referenced_entity WHERE " + user + ".dummy_entity IS NOT NULL");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,11 +139,11 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
|
||||
String sql = sqlGenerator.createDeleteAllSql(PropertyPath.from("ref.further", DummyEntity.class));
|
||||
|
||||
assertThat(sql).isEqualTo(
|
||||
"DELETE FROM " + user + ".second_level_referenced_entity " +
|
||||
"WHERE " + user + ".referenced_entity IN " +
|
||||
"(SELECT l1id FROM " + user + ".referenced_entity " +
|
||||
"WHERE " + user + ".dummy_entity IS NOT NULL)");
|
||||
assertThat(sql).isEqualTo( //
|
||||
"DELETE FROM " + user + ".second_level_referenced_entity " //
|
||||
+ "WHERE " + user + ".referenced_entity IN " //
|
||||
+ "(SELECT l1id FROM " + user + ".referenced_entity " //
|
||||
+ "WHERE " + user + ".dummy_entity IS NOT NULL)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
threadedTest("User2", latch, testAssertions, exception);
|
||||
|
||||
try {
|
||||
if (!latch.await(10L, TimeUnit.SECONDS)){
|
||||
if (!latch.await(10L, TimeUnit.SECONDS)) {
|
||||
fail("Test failed due to a time out.");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
@@ -176,7 +176,8 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
* Inside a {@link Runnable}, fetch the {@link ThreadLocal}-based username and execute the provided set of assertions.
|
||||
* Then signal through the provided {@link CountDownLatch}.
|
||||
*/
|
||||
private void threadedTest(String user, CountDownLatch latch, Consumer<String> testAssertions, AtomicReference<Error> exception) {
|
||||
private void threadedTest(String user, CountDownLatch latch, Consumer<String> testAssertions,
|
||||
AtomicReference<Error> exception) {
|
||||
|
||||
new Thread(() -> {
|
||||
|
||||
|
||||
@@ -126,10 +126,10 @@ public class SqlGeneratorUnitTests {
|
||||
// this would get called when DummyEntity is th element type of a Map
|
||||
String sql = sqlGenerator.getFindAllByProperty("back-ref", "key-column", false);
|
||||
|
||||
assertThat(sql).isEqualTo("SELECT dummy_entity.x_id AS x_id, dummy_entity.x_name AS x_name, "
|
||||
+ "ref.x_l1id AS ref_x_l1id, ref.x_content AS ref_x_content, ref.x_further AS ref_x_further, "
|
||||
+ "dummy_entity.key-column AS key-column "
|
||||
+ "FROM dummy_entity LEFT OUTER JOIN referenced_entity AS ref ON ref.dummy_entity = dummy_entity.x_id "
|
||||
assertThat(sql).isEqualTo("SELECT dummy_entity.x_id AS x_id, dummy_entity.x_name AS x_name, " //
|
||||
+ "ref.x_l1id AS ref_x_l1id, ref.x_content AS ref_x_content, ref.x_further AS ref_x_further, " //
|
||||
+ "dummy_entity.key-column AS key-column " //
|
||||
+ "FROM dummy_entity LEFT OUTER JOIN referenced_entity AS ref ON ref.dummy_entity = dummy_entity.x_id " //
|
||||
+ "WHERE back-ref = :back-ref");
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Insert.class, Element.class, "0", "elements"), //
|
||||
tuple(Insert.class, Element.class, "a", "elements"), //
|
||||
tuple(Insert.class, Element.class, "b", "elements") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-130
|
||||
@@ -328,7 +328,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Delete.class, Element.class, null, "elements"), //
|
||||
tuple(Update.class, MapContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, "one", "elements") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-130
|
||||
@@ -347,7 +347,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Delete.class, Element.class, null, "elements"), //
|
||||
tuple(Update.class, ListContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, 0, "elements") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
private CascadingReferenceMiddleElement createMiddleElement(Element first, Element second) {
|
||||
|
||||
@@ -50,9 +50,12 @@ public class NamingStrategyUnitTests {
|
||||
|
||||
@Test // DATAJDBC-184
|
||||
public void getColumnName() {
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("id"))).isEqualTo("id");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("createdAt"))).isEqualTo("created_at");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("dummySubEntities")))
|
||||
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("id"))) //
|
||||
.isEqualTo("id");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("createdAt"))) //
|
||||
.isEqualTo("created_at");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("dummySubEntities"))) //
|
||||
.isEqualTo("dummy_sub_entities");
|
||||
}
|
||||
|
||||
@@ -64,7 +67,8 @@ public class NamingStrategyUnitTests {
|
||||
|
||||
@Test // DATAJDBC-184
|
||||
public void getKeyColumn() {
|
||||
assertThat(target.getKeyColumn(persistentEntity.getPersistentProperty("dummySubEntities")))
|
||||
|
||||
assertThat(target.getKeyColumn(persistentEntity.getPersistentProperty("dummySubEntities"))) //
|
||||
.isEqualTo("dummy_entity_key");
|
||||
}
|
||||
|
||||
@@ -75,11 +79,13 @@ public class NamingStrategyUnitTests {
|
||||
|
||||
@Test // DATAJDBC-184
|
||||
public void getQualifiedTableName() {
|
||||
|
||||
assertThat(target.getQualifiedTableName(persistentEntity.getType())).isEqualTo("dummy_entity");
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class DummyEntity {
|
||||
|
||||
@Id private int id;
|
||||
private LocalDateTime createdAt;
|
||||
private List<DummySubEntity> dummySubEntities;
|
||||
@@ -87,6 +93,7 @@ public class NamingStrategyUnitTests {
|
||||
|
||||
@Data
|
||||
private static class DummySubEntity {
|
||||
|
||||
@Id private int id;
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ public class JdbcRepositoryIntegrationTests {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ClassRule public static final SpringClassRule classRule = new SpringClassRule();
|
||||
@Rule public SpringMethodRule methodRule = new SpringMethodRule();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user