Search in sources :

Example 6 with DefaultLogger

use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.

the class DefaultClientConfigTests method testOverrideLoggerShouldNotThrow.

@Test
public void testOverrideLoggerShouldNotThrow() {
    final ILogger logger = new DefaultLogger();
    DefaultClientConfig config = new DefaultClientConfig() {

        @Override
        public ILogger getLogger() {
            return logger;
        }

        @Override
        public IAuthenticationProvider getAuthenticationProvider() {
            return new MockAuthenticationProvider();
        }
    };
    config.getExecutors();
    config.getAuthenticationProvider();
    config.getHttpProvider();
    config.getSerializer();
    config.getLogger();
}
Also used : MockAuthenticationProvider(com.microsoft.graph.authentication.MockAuthenticationProvider) ILogger(com.microsoft.graph.logger.ILogger) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.Test)

Example 7 with DefaultLogger

use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.

the class GraphServiceExceptionTests method testCreateFromConnection.

@Test
public void testCreateFromConnection() {
    DefaultLogger logger = new DefaultLogger();
    GraphServiceException exception = null;
    Boolean success = false;
    Boolean failure = false;
    final ITestConnectionData data = new ITestConnectionData() {

        @Override
        public int getRequestCode() {
            return 401;
        }

        @Override
        public String getJsonResponse() {
            return "{}";
        }

        @Override
        public Map<String, String> getHeaders() {
            return new HashMap<>();
        }
    };
    try {
        exception = GraphServiceException.createFromConnection(new MockHttpRequest(), null, null, new MockConnection(data) {
        }, logger);
        success = true;
    } catch (IOException ex) {
        failure = true;
    }
    assertTrue(success);
    assertFalse(failure);
    String message = exception.getMessage();
    assertTrue(message.indexOf("Error code: Unable to parse error response message") == 0);
    assertTrue(message.indexOf("http://localhost") > 0);
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.Test)

Example 8 with DefaultLogger

use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.

the class DefaultSeralizerTests method testRecurrenceRangeDeserialization.

@Test
public void testRecurrenceRangeDeserialization() throws Exception {
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    String source = "{\n" + "    \"type\": \"noEnd\",\n" + "    \"startDate\": \"2016-04-27\",\n" + "    \"endDate\": \"0001-01-01\",\n" + "    \"recurrenceTimeZone\": \"China Standard Time\",\n" + "    \"numberOfOccurrences\": 0\n" + "}";
    BaseRecurrenceRange baseRecurrenceRange = serializer.deserializeObject(source, BaseRecurrenceRange.class);
    assertNotNull(source);
    assertEquals(RecurrenceRangeType.NO_END, baseRecurrenceRange.type);
    assertEquals("2016-04-27", baseRecurrenceRange.startDate.toString());
    assertEquals("0001-01-01", baseRecurrenceRange.endDate.toString());
    assertEquals("China Standard Time", baseRecurrenceRange.recurrenceTimeZone);
    assertEquals(Integer.valueOf(0), baseRecurrenceRange.numberOfOccurrences);
}
Also used : BaseRecurrenceRange(com.microsoft.graph.models.generated.BaseRecurrenceRange) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.Test)

Aggregations

DefaultLogger (com.microsoft.graph.logger.DefaultLogger)8 Test (org.junit.Test)7 BaseRecurrenceRange (com.microsoft.graph.models.generated.BaseRecurrenceRange)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 MockAuthenticationProvider (com.microsoft.graph.authentication.MockAuthenticationProvider)1 MockConnection (com.microsoft.graph.http.MockConnection)1 ILogger (com.microsoft.graph.logger.ILogger)1 Attachment (com.microsoft.graph.models.extensions.Attachment)1 DateOnly (com.microsoft.graph.models.extensions.DateOnly)1 Drive (com.microsoft.graph.models.extensions.Drive)1 FileAttachment (com.microsoft.graph.models.extensions.FileAttachment)1 User (com.microsoft.graph.models.extensions.User)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1