This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEMP example exercising validation code
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import com.equinix.openapi.ApiClient; | ||
import com.equinix.openapi.ApiException; | ||
import com.equinix.openapi.Configuration; | ||
import com.equinix.openapi.JSON; | ||
import com.equinix.openapi.auth.ApiKeyAuth; | ||
import com.equinix.openapi.metal.v1.model.VirtualCircuit; | ||
import com.equinix.openapi.metal.v1.model.VrfVirtualCircuit; | ||
import com.equinix.openapi.metal.v1.model.VlanVirtualCircuit; | ||
|
||
import java.util.UUID; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import java.lang.reflect.Type; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
public class ValidateVirtualCircuit { | ||
public static void main(String[] args) { | ||
String vrfVcString = "{\"id\": \"22A111DD-5EE3-4188-9163-78284363CA73\",\"name\": \"SDDC-2-pop_vpc-VC-primary\",\"status\": \"active\",\"bill\": true,\"nni_vnid\": 264,\"nni_vlan\": 264,\"project\": {\"href\": \"/metal/v1/projects/11CCA184-DB21-4659-A029-B704CDC8D5BA\"},\"vrf\": {\"href\": \"/metal/v1/vrfs/E3DEC139-F2A7-401F-BA12-890F206EF3FD\"},\"type\": \"vrf\",\"vnid\": null}"; | ||
String vlanVcString = "{\"id\": \"22A111DD-5EE3-4188-9163-78284363CA73\",\"name\": \"SDDC-2-pop_vpc-VC-primary\",\"status\": \"active\",\"bill\": true,\"nni_vnid\": 264,\"nni_vlan\": 264,\"project\": {\"href\": \"/metal/v1/projects/11CCA184-DB21-4659-A029-B704CDC8D5BA\"},\"vrf\": {\"href\": \"/metal/v1/vrfs/E3DEC139-F2A7-401F-BA12-890F206EF3FD\"},\"type\": \"vlan\",\"vnid\": null}"; | ||
|
||
try{ | ||
// no error from oneOf | ||
JSON json = new JSON(); | ||
Type localVarReturnType = new TypeToken<VirtualCircuit>(){}.getType(); | ||
JSON.deserialize(vlanVcString, localVarReturnType); | ||
JSON.deserialize(vrfVcString, localVarReturnType); | ||
} catch (Exception e) { | ||
System.out.println(String.format("Exception message : %s", e.getMessage())); | ||
e.printStackTrace(); | ||
} | ||
|
||
|
||
try{ | ||
System.out.println("validation error from vrf vc when type is vlan"); | ||
JSON json = new JSON(); | ||
Type localVarReturnType = new TypeToken<VrfVirtualCircuit>(){}.getType(); | ||
JSON.deserialize(vlanVcString, localVarReturnType); | ||
} catch (Exception e) { | ||
System.out.println(String.format("Exception message : %s", e.getMessage())); | ||
e.printStackTrace(); | ||
} | ||
|
||
try{ | ||
System.out.println("validation error from vlan vc when type is vrf"); | ||
JSON json = new JSON(); | ||
Type localVarReturnType = new TypeToken<VlanVirtualCircuit>(){}.getType(); | ||
JSON.deserialize(vrfVcString, localVarReturnType); | ||
} catch (Exception e) { | ||
System.out.println(String.format("Exception message : %s", e.getMessage())); | ||
e.printStackTrace(); | ||
} | ||
|
||
|
||
try{ | ||
JSON json = new JSON(); | ||
Type localVarReturnType = new TypeToken<VirtualCircuit>(){}.getType(); | ||
JSON.deserialize(vlanVcString, localVarReturnType); | ||
JSON.deserialize(vrfVcString, localVarReturnType); | ||
} catch (Exception e) { | ||
System.out.println(String.format("Exception message : %s", e.getMessage())); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |