Skip to content

Commit

Permalink
Bump coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Omondi committed Apr 2, 2024
1 parent f6ca2e4 commit 03d9d28
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.*;

import com.google.gson.JsonParser;
import com.microsoft.kiota.serialization.mocks.MyEnum;
import com.microsoft.kiota.serialization.mocks.TestEntity;
import com.microsoft.kiota.serialization.mocks.UntypedTestEntity;

Expand All @@ -19,7 +20,8 @@ class JsonParseNodeTests {
private static final String contentType = "application/json";

private static final String testJsonString =
"{\"displayName\":\"My Group\",\"id\":\"11111111-1111-1111-1111-111111111111"
"{\"displayName\":\"My"
+ " Group\",\"phones\":[\"+1234567890\"],\"myEnum\":\"VALUE1\",\"enumCollection\":[\"VALUE1\"],\"id\":\"11111111-1111-1111-1111-111111111111"
+ "\",\"members@delta\":[{\"@odata.type\":\"#microsoft.graph.user\",\"id\":\"22222222-2222-2222-2222-222222222222\"}]}";
private static final String testUntypedJson =
"{\r\n"
Expand Down Expand Up @@ -107,6 +109,9 @@ void getEntityWithArrayInAdditionalData() throws UnsupportedEncodingException {
// Act
var entity = parseNode.getObjectValue(TestEntity::createFromDiscriminatorValue);
assertEquals("11111111-1111-1111-1111-111111111111", entity.getId());
assertEquals(1, entity.getPhones().size());
assertEquals(MyEnum.MY_VALUE1, entity.getMyEnum());
assertEquals(1, entity.getEnumCollection().size());
final var arrayValue = (UntypedArray) entity.getAdditionalData().get("members@delta");
assertEquals(1, arrayValue.getValue().spliterator().estimateSize());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
Expand All @@ -25,6 +27,16 @@ public void setId(String _id) {
this._id = _id;
}

private List<String> _phones;

public List<String> getPhones() {
return _phones;
}

public void setPhones(List<String> _phones) {
this._phones = new ArrayList<String>(_phones);
}

private String _officeLocation;

public String getOfficeLocation() {
Expand Down Expand Up @@ -85,6 +97,16 @@ public void setMyEnum(MyEnum value) {
this._myEnum = value;
}

private List<MyEnum> _enumCollection;

public List<MyEnum> getEnumCollection() {
return _enumCollection;
}

public void setEnumCollection(List<MyEnum> value) {
this._enumCollection = new ArrayList<MyEnum>(value);
}

private OffsetDateTime _createdDateTime;

public OffsetDateTime getCreatedDateTime() {
Expand Down Expand Up @@ -134,11 +156,21 @@ public Map<String, Consumer<ParseNode>> getFieldDeserializers() {
(n) -> {
setMyEnum(n.getEnumValue(MyEnum::forValue));
});
put(
"enumCollection",
(n) -> {
setEnumCollection(n.getCollectionOfEnumValues(MyEnum::forValue));
});
put(
"createdDateTime",
(n) -> {
setCreatedDateTime(n.getOffsetDateTimeValue());
});
put(
"phones",
(n) -> {
setPhones(n.getCollectionOfPrimitiveValues(String.class));
});
}
};
}
Expand All @@ -153,7 +185,9 @@ public void serialize(SerializationWriter writer) {
writer.writeLocalTimeValue("startWorkTime", getStartWorkTime());
writer.writeLocalTimeValue("endWorkTime", getEndWorkTime());
writer.writeEnumValue("myEnum", getMyEnum());
writer.writeCollectionOfEnumValues("enumCollection", getEnumCollection());
writer.writeOffsetDateTimeValue("createdDateTime", getCreatedDateTime());
writer.writeCollectionOfPrimitiveValues("phones", getPhones());
writer.writeAdditionalData(getAdditionalData());
}

Expand Down

0 comments on commit 03d9d28

Please sign in to comment.