Skip to content

DefaultSerializer can't unit class.  #300

@valenpo

Description

@valenpo

MS return JSON "@odata.type":"#Microsoft.Graph.Message" in some messages, and conversion to proper package class will fail. It is not on DefaultSerializer.

Package name should be lowercase.

        final String derivedType = (odataType.substring(0, lastDotIndex).toLowerCase()
@Test
    public void fail() throws ClassNotFoundException {
        String odataType = "#Microsoft.Graph.Message";

        final int lastDotIndex = odataType.lastIndexOf(".");
        final String derivedType = (odataType.substring(0, lastDotIndex) +
                ".models." +
                CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,
                        odataType.substring(lastDotIndex + 1)))
                .replace("#", "com.");

        Class<?> derivedClass = Class.forName(derivedType);
        System.out.println(derivedClass);


    }

    @Test
    public void pass() throws ClassNotFoundException {
        String odataType = "#Microsoft.Graph.Message";

        final int lastDotIndex = odataType.lastIndexOf(".");
        final String derivedType = (odataType.substring(0, lastDotIndex).toLowerCase() +
                ".models." +
                CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,
                        odataType.substring(lastDotIndex + 1)))
                .replace("#", "com.");

        Class<?> derivedClass = Class.forName(derivedType);
        System.out.println(derivedClass);
    }

AB#10928

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions