88import java .util .Arrays ;
99import java .util .HashMap ;
1010import java .util .Map ;
11- import java .util .concurrent .atomic .AtomicBoolean ;
1211
1312import org .junit .Test ;
1413
1514import com .google .gson .JsonObject ;
1615import com .google .gson .JsonPrimitive ;
1716import com .microsoft .graph .authentication .MockAuthenticationProvider ;
18- import com .microsoft .graph .concurrency .IProgressCallback ;
1917import com .microsoft .graph .concurrency .MockExecutors ;
20- import com .microsoft .graph .core .ClientException ;
2118import com .microsoft .graph .core .GraphErrorCodes ;
2219import com .microsoft .graph .logger .LoggerLevel ;
2320import com .microsoft .graph .logger .MockLogger ;
24- import com .microsoft .graph .models .extensions .Drive ;
2521import com .microsoft .graph .models .extensions .DriveItem ;
2622import com .microsoft .graph .options .HeaderOption ;
2723import com .microsoft .graph .serializer .MockSerializer ;
@@ -31,89 +27,6 @@ public class CoreHttpProviderTests {
3127 private MockAuthenticationProvider mAuthenticationProvider ;
3228 private CoreHttpProvider mProvider ;
3329
34- @ Test
35- public void testNoContentType () throws Exception {
36- final ITestConnectionData data = new ITestConnectionData () {
37- @ Override
38- public int getRequestCode () {
39- return 200 ;
40- }
41-
42- @ Override
43- public String getJsonResponse () {
44- return "{ \" id\" : \" zzz\" }" ;
45- }
46-
47- @ Override
48- public Map <String , String > getHeaders () {
49- return new HashMap <>();
50- }
51- };
52- setDefaultHttpProvider (null );
53-
54- try {
55- mProvider .send (new MockHttpRequest (), Drive .class , null );
56- fail ("Expected exception" );
57- } catch (final ClientException ce ) {
58- if (!(ce .getCause () instanceof NullPointerException )) {
59- fail ("Wrong inner exception!" );
60- }
61- }
62- assertEquals (1 , mAuthenticationProvider .getInterceptionCount ());
63- }
64-
65- @ Test
66- public void testPostByte () throws Exception {
67- final String itemId = "itemId" ;
68- final ITestConnectionData data = new ITestConnectionData () {
69- @ Override
70- public int getRequestCode () {
71- return 200 ;
72- }
73-
74- @ Override
75- public String getJsonResponse () {
76- return "{ \" id\" : \" zzz\" }" ;
77- }
78-
79- @ Override
80- public Map <String , String > getHeaders () {
81- final HashMap <String , String > map = new HashMap <>();
82- map .put ("Content-Type" , "application/json" );
83- return map ;
84- }
85- };
86- final DriveItem expectedItem = new DriveItem ();
87- expectedItem .id = itemId ;
88- setDefaultHttpProvider (expectedItem );
89-
90- final AtomicBoolean progress = new AtomicBoolean (false );
91- final AtomicBoolean success = new AtomicBoolean (false );
92- final AtomicBoolean failure = new AtomicBoolean (false );
93- final IProgressCallback <DriveItem > progressCallback = new IProgressCallback <DriveItem >() {
94- @ Override
95- public void progress (final long current , final long max ) {
96- progress .set (true );
97- }
98-
99- @ Override
100- public void success (final DriveItem item ) {
101- success .set (true );
102- }
103-
104- @ Override
105- public void failure (final ClientException ex ) {
106- failure .set (true );
107- }
108- };
109-
110- mProvider .send (new MockHttpRequest (), progressCallback , DriveItem .class , new byte []{1 , 2 , 3 , 4 });
111-
112- assertTrue (progress .get ());
113- assertTrue (success .get ());
114- assertEquals (1 , mAuthenticationProvider .getInterceptionCount ());
115- }
116-
11730 @ Test
11831 public void testErrorResponse () throws Exception {
11932 final GraphErrorCodes expectedErrorCode = GraphErrorCodes .INVALID_REQUEST ;
0 commit comments