Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> addi
resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
}
}
String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier());
String id = resultMapNode.getStringAttribute("id", resultMapNode::getValueBasedIdentifier);
String extend = resultMapNode.getStringAttribute("extends");
Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend, discriminator,
Expand Down Expand Up @@ -289,8 +289,7 @@ private Discriminator processDiscriminatorElement(XNode context, Class<?> result
Map<String, String> discriminatorMap = new HashMap<>();
for (XNode caseChild : context.getChildren()) {
String value = caseChild.getStringAttribute("value");
String resultMap = caseChild.getStringAttribute("resultMap",
processNestedResultMappings(caseChild, resultMappings, resultType));
String resultMap = caseChild.getStringAttribute("resultMap", () -> processNestedResultMappings(caseChild, resultMappings, resultType));
discriminatorMap.put(value, resultMap);
}
return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass,
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/org/apache/ibatis/type/TypeAliasRegistryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.apache.ibatis.type;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -75,4 +76,21 @@ void shouldFetchCharType() {
assertEquals(char[].class, typeAliasRegistry.resolveAlias("_char[]"));
}

@Test
void shouldNotBeAbleToRegisterAliasWithEmptyString() {
TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry();

assertThatThrownBy(() -> typeAliasRegistry.registerAlias("foo", ""))
.isInstanceOf(TypeException.class)
.hasMessageContaining("Error registering type alias foo for");
}

@Test
void shouldNotBeAbleToResolveNotExistsAlias() {
TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry();

assertThatThrownBy(() -> typeAliasRegistry.resolveAlias("abc"))
.isInstanceOf(TypeException.class)
.hasMessageContaining("Could not resolve type alias 'abc'. Cause: java.lang.ClassNotFoundException: Cannot find class: abc");
}
}
Loading