Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Simplify code. Remove redundant calls.

Reformat code, remove trailing whitespaces, remove duplicate tests.

See #1802
Original pull request: #1810
  • Loading branch information
mp911de committed Jun 10, 2024
1 parent 9e12d0a commit 702002a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.context.ApplicationContextAware;
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.converter.Converter;
Expand All @@ -45,7 +46,6 @@
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import org.springframework.data.relational.core.sql.SqlIdentifier;
import org.springframework.data.relational.domain.RowDocument;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
Expand Down Expand Up @@ -384,15 +384,14 @@ public <T> T getPropertyValue(RelationalPersistentProperty property) {
// references and possibly keys, that form an id
if (idDefiningParentPath.hasIdProperty()) {

Class<?> idType = idDefiningParentPath.getRequiredIdProperty().getActualType();
//
RelationalPersistentProperty requiredIdProperty = idDefiningParentPath.getRequiredIdProperty();
AggregatePath idPath = idDefiningParentPath.append(requiredIdProperty);
Object idValue = delegate.getValue(idPath);
RelationalPersistentProperty identifier = idDefiningParentPath.getRequiredIdProperty();
AggregatePath idPath = idDefiningParentPath.append(identifier);
Object value = delegate.getValue(idPath);

Assert.state(idValue != null, "idValue must not be null at this point");
Assert.state(value != null, "Identifier value must not be null at this point");

identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), idValue, idType);
identifierToUse = Identifier.of(aggregatePath.getTableInfo().reverseColumnInfo().name(), value,
identifier.getActualType());
}

Iterable<Object> allByPath = relationResolver.findAllByPath(identifierToUse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.SoftAssertions.*;
import static org.springframework.data.jdbc.testing.TestConfiguration.*;
import static org.springframework.data.jdbc.testing.TestDatabaseFeatures.Feature.*;

Expand Down Expand Up @@ -1294,7 +1295,7 @@ void singleEntitySetChain() {
First first1Reloaded = template.findById(first1.id, First.class);
First first2Reloaded = template.findById(first2.id, First.class);

SoftAssertions.assertSoftly(softly ->{
assertSoftly(softly -> {
softly.assertThat(first1Reloaded).isEqualTo(first1);
softly.assertThat(first2Reloaded).isEqualTo(first2);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ void isEmbedded() {
softly.assertThat(path("second2.third").isEmbedded()).isFalse();
softly.assertThat(path("second2.third2").isEmbedded()).isTrue();
softly.assertThat(path("second2").isEmbedded()).isTrue();

});
}

Expand Down Expand Up @@ -467,20 +466,6 @@ void getEffectiveIdColumnName() {
});
}

@Test // GH-1802
void dingens() {

assertSoftly(softly -> {

AggregatePath.TableInfo tableInfo = path("withId.second.third").getTableInfo();
AggregatePath idDefiningParentPath = path("withId.second.third").getIdDefiningParentPath();
AggregatePath.TableInfo parentTable = idDefiningParentPath.getTableInfo();
softly.assertThat(tableInfo.effectiveIdColumnName())
.isEqualTo(quoted("WITH_ID"));

});
}

@Test // GH-1525
void getLength() {

Expand Down

0 comments on commit 702002a

Please sign in to comment.