Skip to content

Commit 9d17a49

Browse files
committed
correctly return hashset as array
1 parent 425a89d commit 9d17a49

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/com/microsoft/graph/authentication/BaseAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void setCustomHosts(@Nonnull String[] customHosts) {
3333
*/
3434
@Nullable
3535
public String[] getCustomHosts(){
36-
return (String[]) this.customHosts.toArray();
36+
return customHosts.toArray(new String[customHosts.size()]);
3737
}
3838
/**
3939
* Determines whether a request should be authenticated or not based on it's url.

src/test/java/com/microsoft/graph/authentication/BaseAuthenticationProviderTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.microsoft.graph.authentication;
22

3-
import static org.junit.jupiter.api.Assertions.assertFalse;
4-
import static org.junit.jupiter.api.Assertions.assertTrue;
5-
63
import java.net.MalformedURLException;
74
import java.net.URL;
85
import java.util.Arrays;
@@ -11,6 +8,8 @@
118

129
import org.junit.jupiter.api.Test;
1310

11+
import static org.junit.jupiter.api.Assertions.*;
12+
1413
public class BaseAuthenticationProviderTest {
1514
final BaseAuthenticationProvider authProvider = new BaseAuthenticationProvider() {
1615

@@ -78,5 +77,7 @@ public void providerAddsTokenToCustomHosts() throws MalformedURLException {
7877

7978
//Assert
8079
assertTrue(result);
80+
assertEquals(authProvider.getCustomHosts().length, 1);
81+
assertEquals(authProvider.getCustomHosts()[0], "localhost.com");
8182
}
8283
}

0 commit comments

Comments
 (0)