Skip to content

Commit

Permalink
Updates code to latest PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Omondi committed Mar 6, 2024
1 parent 9605457 commit 2ba12dc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
19 changes: 10 additions & 9 deletions json_parse_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/google/uuid"
"io"
"time"

"github.com/google/uuid"

abstractions "github.com/microsoft/kiota-abstractions-go"
absser "github.com/microsoft/kiota-abstractions-go/serialization"
)
Expand Down Expand Up @@ -192,17 +193,17 @@ func (n *JsonParseNode) GetObjectValue(ctor absser.ParsableFactory) (absser.Pars
if isUntypedNode {
switch value := n.value.(type) {
case *bool:
return absser.NewUntypedBoolean(value), nil
return absser.NewUntypedBoolean(value)

Check failure on line 196 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / build

undefined: absser.NewUntypedBoolean

Check failure on line 196 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / SonarCloud

undefined: absser.NewUntypedBoolean
case *string:
return absser.NewUntypedString(value), nil
return absser.NewUntypedString(value)

Check failure on line 198 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / build

undefined: absser.NewUntypedString

Check failure on line 198 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / SonarCloud

undefined: absser.NewUntypedString
case *float32:
return absser.NewUntypedFloat(value), nil
return absser.NewUntypedFloat(value)

Check failure on line 200 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / build

undefined: absser.NewUntypedFloat

Check failure on line 200 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / SonarCloud

undefined: absser.NewUntypedFloat
case *float64:
return absser.NewUntypedDouble(value), nil
return absser.NewUntypedDouble(value)

Check failure on line 202 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / build

undefined: absser.NewUntypedDouble

Check failure on line 202 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / SonarCloud

undefined: absser.NewUntypedDouble
case *int32:
return absser.NewUntypedInteger(value), nil
return absser.NewUntypedInteger(value)

Check failure on line 204 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / build

undefined: absser.NewUntypedInteger

Check failure on line 204 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / SonarCloud

undefined: absser.NewUntypedInteger
case *int64:
return absser.NewUntypedLong(value), nil
return absser.NewUntypedLong(value)

Check failure on line 206 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / build

undefined: absser.NewUntypedLong

Check failure on line 206 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / SonarCloud

undefined: absser.NewUntypedLong
case nil:
return absser.NewUntypedNull(), nil

Check failure on line 208 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / build

undefined: absser.NewUntypedNull

Check failure on line 208 in json_parse_node.go

View workflow job for this annotation

GitHub Actions / SonarCloud

undefined: absser.NewUntypedNull
case map[string]*JsonParseNode:
Expand All @@ -220,7 +221,7 @@ func (n *JsonParseNode) GetObjectValue(ctor absser.ParsableFactory) (absser.Pars
properties[key] = property
}
}
return absser.NewUntypedObject(properties), nil
return absser.NewUntypedObject(properties)
case []*JsonParseNode:
collection := make([]absser.UntypedNodeable, len(value))
for index, node := range value {
Expand All @@ -237,7 +238,7 @@ func (n *JsonParseNode) GetObjectValue(ctor absser.ParsableFactory) (absser.Pars
}

}
return absser.NewUntypedArray(collection), nil
return absser.NewUntypedArray(collection)
default:
return absser.NewUntypedNode(value), nil
}
Expand Down
51 changes: 26 additions & 25 deletions json_serialization_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,63 +587,64 @@ func TestWriteUntypedJson(t *testing.T) {

addressProperties := make(map[string]absser.UntypedNodeable)
city := "Redmond"
addressProperties["city"] = absser.NewUntypedString(&city)
addressProperties["city"], _ = absser.NewUntypedString(&city)
postalCode := "98052"
addressProperties["postalCode"] = absser.NewUntypedString(&postalCode)
addressProperties["postalCode"], _ = absser.NewUntypedString(&postalCode)
state := "Washington"
addressProperties["state"] = absser.NewUntypedString(&state)
addressProperties["state"], _ = absser.NewUntypedString(&state)
street := "NE 36th St"
addressProperties["street"] = absser.NewUntypedString(&street)
addressProperties["street"], _ = absser.NewUntypedString(&street)

locationProperties["address"] = absser.NewUntypedObject(addressProperties)
locationProperties["address"], _ = absser.NewUntypedObject(addressProperties)

coordinatesProperties := make(map[string]absser.UntypedNodeable)
latitude := 47.641942
coordinatesProperties["latitude"] = absser.NewUntypedDouble(&latitude)
coordinatesProperties["latitude"], _ = absser.NewUntypedDouble(&latitude)
longitude := -122.127222
coordinatesProperties["longitude"] = absser.NewUntypedDouble(&longitude)
coordinatesProperties["longitude"], _ = absser.NewUntypedDouble(&longitude)

locationProperties["coordinates"] = absser.NewUntypedObject(coordinatesProperties)
locationProperties["coordinates"], _ = absser.NewUntypedObject(coordinatesProperties)

displayName := "Microsoft Building 92"
locationProperties["displayName"] = absser.NewUntypedString(&displayName)
locationProperties["displayName"], _ = absser.NewUntypedString(&displayName)
floorCount := int32(50)
locationProperties["floorCount"] = absser.NewUntypedInteger(&floorCount)
locationProperties["floorCount"], _ = absser.NewUntypedInteger(&floorCount)
hasReception := true
locationProperties["hasReception"] = absser.NewUntypedBoolean(&hasReception)
locationProperties["hasReception"], _ = absser.NewUntypedBoolean(&hasReception)
locationProperties["contact"] = absser.NewUntypedNull()
location := absser.NewUntypedObject(locationProperties)
location, _ := absser.NewUntypedObject(locationProperties)
untypedTestEntity.SetLocation(location)

keywords := make([]absser.UntypedNodeable, 2)
firstKeywordProperties := make(map[string]absser.UntypedNodeable)
created := "2023-07-26T10:41:26Z"
firstKeywordProperties["created"] = absser.NewUntypedString(&created)
firstKeywordProperties["created"], _ = absser.NewUntypedString(&created)
label := "Keyword1"
firstKeywordProperties["label"] = absser.NewUntypedString(&label)
firstKeywordProperties["label"], _ = absser.NewUntypedString(&label)
termGuid := "10e9cc83-b5a4-4c8d-8dab-4ada1252dd70"
firstKeywordProperties["termGuid"] = absser.NewUntypedString(&termGuid)
firstKeywordProperties["termGuid"], _ = absser.NewUntypedString(&termGuid)
wssId := int64(6442450941)
firstKeywordProperties["wssId"] = absser.NewUntypedLong(&wssId)
keywords[0] = absser.NewUntypedObject(firstKeywordProperties)
firstKeywordProperties["wssId"], _ = absser.NewUntypedLong(&wssId)
keywords[0], _ = absser.NewUntypedObject(firstKeywordProperties)

secondKeywordProperties := make(map[string]absser.UntypedNodeable)
created = "2023-07-26T10:51:26Z"
secondKeywordProperties["created"] = absser.NewUntypedString(&created)
secondKeywordProperties["created"], _ = absser.NewUntypedString(&created)
label = "Keyword2"
secondKeywordProperties["label"] = absser.NewUntypedString(&label)
secondKeywordProperties["label"], _ = absser.NewUntypedString(&label)
termGuid = "2cae6c6a-9bb8-4a78-afff-81b88e735fef"
secondKeywordProperties["termGuid"] = absser.NewUntypedString(&termGuid)
secondKeywordProperties["termGuid"], _ = absser.NewUntypedString(&termGuid)
wssId = int64(6442450942)
secondKeywordProperties["wssId"] = absser.NewUntypedLong(&wssId)
keywords[1] = absser.NewUntypedObject(secondKeywordProperties)
secondKeywordProperties["wssId"], _ = absser.NewUntypedLong(&wssId)
keywords[1], _ = absser.NewUntypedObject(secondKeywordProperties)

untypedTestEntity.SetKeywords(absser.NewUntypedArray(keywords))
untypedKeywordsArray, _ := absser.NewUntypedArray(keywords)
untypedTestEntity.SetKeywords(untypedKeywordsArray)

extraProperties := make(map[string]absser.UntypedNodeable)
createdDateTime := "2024-01-15T00:00:00+00:00"
extraProperties["createdDateTime"] = absser.NewUntypedString(&createdDateTime)
extra := absser.NewUntypedObject(extraProperties)
extraProperties["createdDateTime"], _ = absser.NewUntypedString(&createdDateTime)
extra, _ := absser.NewUntypedObject(extraProperties)
additionalData := make(map[string]interface{})
additionalData["extra"] = extra
untypedTestEntity.SetAdditionalData(additionalData)
Expand Down

0 comments on commit 2ba12dc

Please sign in to comment.