Skip to content

Commit

Permalink
Use fully qualified identifiers for java.util.function.Consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Jan 26, 2023
1 parent ec1cfe1 commit 43fbd32
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Using fully qualified identifier for java.util.function.Consumer to avoid conflicts in Java.
- Removed response handler parameter from PHP request executor methods. [1856](https://github.com/microsoft/kiota/issues/1856)
- Fixed minor typo in adding Accept header for PHP.
- Fixed a bug with null reference types and composed types in CSharp.
Expand Down
4 changes: 1 addition & 3 deletions src/Kiota.Builder/Refiners/JavaRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ private static void AddEnumSetImport(CodeElement currentElement) {
"com.microsoft.kiota.serialization", "ParseNode"),
new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor),
"com.microsoft.kiota.serialization", "Parsable", "ParsableFactory"),
new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer),
"java.util.function", "Consumer"),
new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer),
"java.util", "HashMap", "Map"),
new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.ClientConstructor) &&
Expand Down Expand Up @@ -230,7 +228,7 @@ private static void CorrectMethodType(CodeMethod currentMethod) {
x.Type.Name = x.Type.Name[1..];
});
else if(currentMethod.IsOfKind(CodeMethodKind.Deserializer)) {
currentMethod.ReturnType.Name = "Map<String, Consumer<ParseNode>>";
currentMethod.ReturnType.Name = "Map<String, java.util.function.Consumer<ParseNode>>";
currentMethod.Name = "getFieldDeserializers";
}
else if(currentMethod.IsOfKind(CodeMethodKind.ClientConstructor, CodeMethodKind.Constructor, CodeMethodKind.RawUrlConstructor)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private void WriteDeserializerBody(CodeMethod codeElement, CodeClass parentClass
else
WriteDeserializerBodyForInheritedModel(codeElement, parentClass, writer, inherits);
}
private const string DeserializerReturnType = "HashMap<String, Consumer<ParseNode>>";
private const string DeserializerReturnType = "HashMap<String, java.util.function.Consumer<ParseNode>>";
private static void WriteDeserializerBodyForUnionModel(CodeMethod method, CodeClass parentClass, LanguageWriter writer)
{
var includeElse = false;
Expand Down
12 changes: 6 additions & 6 deletions tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,16 +1015,16 @@ public void WritesUnionDeSerializerBody() {
Kind = CodeMethodKind.Deserializer,
IsAsync = false,
ReturnType = new CodeType {
Name = "Map<String, Consumer<ParseNode>>",
Name = "Map<String, java.util.function.Consumer<ParseNode>>",
},
}).First();
writer.Write(deserializationMethod);
var result = tw.ToString();
Assert.DoesNotContain("final UnionTypeWrapper res =", result);
Assert.Contains("this.getComplexType1Value() != null", result);
Assert.Contains("return this.getComplexType1Value().getFieldDeserializers()", result);
Assert.Contains("new HashMap<String, Consumer<ParseNode>>()", result);
AssertExtensions.Before("return this.getComplexType1Value().getFieldDeserializers()", "new HashMap<String, Consumer<ParseNode>>", result);
Assert.Contains("new HashMap<String, java.util.function.Consumer<ParseNode>>()", result);
AssertExtensions.Before("return this.getComplexType1Value().getFieldDeserializers()", "new HashMap<String, java.util.function.Consumer<ParseNode>>", result);
AssertExtensions.CurlyBracesAreClosed(result);
}
[Fact]
Expand All @@ -1035,16 +1035,16 @@ public void WritesIntersectionDeSerializerBody() {
Kind = CodeMethodKind.Deserializer,
IsAsync = false,
ReturnType = new CodeType {
Name = "Map<String, Consumer<ParseNode>>",
Name = "Map<String, java.util.function.Consumer<ParseNode>>",
},
}).First();
writer.Write(deserializationMethod);
var result = tw.ToString();
Assert.DoesNotContain("final IntersectionTypeWrapper res =", result);
Assert.Contains("this.getComplexType1Value() != null || this.getComplexType3Value() != null", result);
Assert.Contains("return ParseNodeHelper.mergeDeserializersForIntersectionWrapper(this.getComplexType1Value(), this.getComplexType3Value())", result);
Assert.Contains("new HashMap<String, Consumer<ParseNode>>()", result);
AssertExtensions.Before("return ParseNodeHelper.mergeDeserializersForIntersectionWrapper(this.getComplexType1Value(), this.getComplexType3Value())", "new HashMap<String, Consumer<ParseNode>>()", result);
Assert.Contains("new HashMap<String, java.util.function.Consumer<ParseNode>>()", result);
AssertExtensions.Before("return ParseNodeHelper.mergeDeserializersForIntersectionWrapper(this.getComplexType1Value(), this.getComplexType3Value())", "new HashMap<String, java.util.function.Consumer<ParseNode>>()", result);
AssertExtensions.CurlyBracesAreClosed(result);
}
[Fact]
Expand Down

0 comments on commit 43fbd32

Please sign in to comment.