### Question:
GcpStackUtil { public static boolean isNewSubnetInExistingNetwork(Network network) { return isExistingNetwork(network) && !isExistingSubnet(network); } private  GcpStackUtil(); static Compute buildCompute(CloudCredential gcpCredential); static GoogleCredential buildCredential(CloudCredential gcpCredential, HttpTransport httpTransport); static String getServiceAccountPrivateKey(CloudCredential credential); static String getServiceAccountCredentialJson(CloudCredential credential); static String getServiceAccountId(CloudCredential credential); static String getProjectId(CloudCredential credential); static CloudCredential prepareCredential(CloudCredential credential); static boolean isOperationFinished(Operation operation); static boolean isOperationFinished(com.google.api.services.sqladmin.model.Operation operation); static GlobalOperations.Get globalOperations(Compute compute, String projectId, String operationName); static SQLAdmin.Operations.Get sqlAdminOperations(SQLAdmin sqlAdmin, String projectId, String operationName); static ZoneOperations.Get zoneOperations(Compute compute, String projectId, String operationName, AvailabilityZone region); static Get regionOperations(Compute compute, String projectId, String operationName, Region region); static Storage buildStorage(CloudCredential gcpCredential, String name); static SQLAdmin buildSQLAdmin(CloudCredential gcpCredential, String name); static String getBucket(String image); static String getTarName(String image); static String getBucketName(String objectStorageLocation); static String getPath(String objectStorageLocation); static String getImageName(String image); static String getAmbariImage(String projectId, String image); static Long getPrivateId(String resourceName); static boolean isExistingNetwork(Network network); static String getNetworkIpRange(Network network); static boolean isNetworkIpRangeDefined(Network network); static boolean isNewSubnetInExistingNetwork(Network network); static boolean isNewNetworkAndSubnet(Network network); static boolean isLegacyNetwork(Network network); static boolean isExistingSubnet(Network network); static String getCustomNetworkId(Network network); static String getSubnetId(Network network); static String getSharedProjectId(Network network); static Boolean noPublicIp(Network network); static Boolean noFirewallRules(Network network); static String getClusterTag(CloudContext cloudContext); static String getGroupClusterTag(CloudContext cloudContext, Group group); static CloudKMS buildCloudKMS(CloudCredential cloudCredential); static final String GCP; static final String JSON; static final String NETWORK_ID; static final String NETWORK_IP_RANGE; static final String SHARED_PROJECT_ID; static final String SUBNET_ID; static final String SERVICE_ACCOUNT; static final String PROJECT_ID; static final String PRIVATE_KEY; static final String CREDENTIAL_JSON; static final String NO_PUBLIC_IP; static final String NO_FIREWALL_RULES; static final String REGION; }### Answer:
@Test public void testNewSubnetInExistingNetworkNoNetwork() { Network network = new Network(new Subnet("")); assertFalse(GcpStackUtil.isNewSubnetInExistingNetwork(network)); }
@Test public void testNewSubnetInExistingNetworkWithNetwork() { Map<String, Object> parameters = new HashMap<>(); parameters.put(GcpStackUtil.NETWORK_ID, "asdf"); Network network = new Network(new Subnet(""), parameters); assertTrue(GcpStackUtil.isNewSubnetInExistingNetwork(network)); }
@Test public void testNewSubnetInExistingNetworkWithNetworkWithSubnet() { Map<String, Object> parameters = new HashMap<>(); parameters.put(GcpStackUtil.NETWORK_ID, "asdf"); parameters.put(GcpStackUtil.SUBNET_ID, "asdf"); Network network = new Network(new Subnet(""), parameters); assertFalse(GcpStackUtil.isNewSubnetInExistingNetwork(network)); }