Source:
<code>public APIDTO addAPI(APIRequest apiRequest, String osVersion) throws ApiException { APIDTO body = new APIDTO(); body.setName(apiRequest.getName()); body.setContext(apiRequest.getContext()); body.setVersion(apiRequest.getVersion()); if (apiRequest.getVisibility() != null) { body.setVisibility(APIDTO.VisibilityEnum.valueOf(apiRequest.getVisibility().toUpperCase())); } else { body.setVisibility(APIDTO.VisibilityEnum.PUBLIC); } body.setDescription(apiRequest.getDescription()); body.setProvider(apiRequest.getProvider()); ArrayList<String> transports = new ArrayList<>(); <START> if (apiRequest.getHttp_checked().equals(Constants.PROTOCOL_HTTP)){ <END> transports.add(Constants.PROTOCOL_HTTP); } if (apiRequest.getHttps_checked().equals(Constants.PROTOCOL_HTTPS)){ transports.add(Constants.PROTOCOL_HTTPS); } body.setTransport(transports); body.isDefaultVersion(false); body.setCacheTimeout(100); ArrayList<String> gatewayEnvironments = new ArrayList<>(); gatewayEnvironments.add(apiRequest.getEnvironment()); body.setGatewayEnvironments(gatewayEnvironments); body.setOperations(apiRequest.getOperationsDTOS()); body.setMediationPolicies(apiRequest.getMediationPolicies()); body.setBusinessInformation(new APIBusinessInformationDTO()); body.setCorsConfiguration(new APICorsConfigurationDTO()); body.setTags(Arrays.asList(apiRequest.getTags().split(","))); body.setEndpointConfig(apiRequest.getEndpointConfig()); body.setSecurityScheme(apiRequest.getSecurityScheme()); List<String> tierList = new ArrayList<>(); tierList.add(Constants.TIERS_UNLIMITED); body.setPolicies(Arrays.asList(apiRequest.getTiersCollection().split(","))); body.isDefaultVersion(Boolean.valueOf(apiRequest.getDefault_version_checked())); APIDTO apidto; try { ApiResponse<APIDTO> httpInfo = apIsApi.apisPostWithHttpInfo(body, osVersion); Assert.assertEquals(201, httpInfo.getStatusCode()); apidto = httpInfo.getData(); } catch (ApiException e) { if (e.getResponseBody().contains("already exists")) { return null; } throw new ApiException(e); } return apidto; }</code><technical_language>swap equals avoid NPE</technical_language>

Target:
public APIDTO addAPI(APIRequest apiRequest, String osVersion) throws ApiException { APIDTO body = new APIDTO(); body.setName(apiRequest.getName()); body.setContext(apiRequest.getContext()); body.setVersion(apiRequest.getVersion()); if (apiRequest.getVisibility() != null) { body.setVisibility(APIDTO.VisibilityEnum.valueOf(apiRequest.getVisibility().toUpperCase())); } else { body.setVisibility(APIDTO.VisibilityEnum.PUBLIC); } body.setDescription(apiRequest.getDescription()); body.setProvider(apiRequest.getProvider()); ArrayList<String> transports = new ArrayList<>(); if (Constants.PROTOCOL_HTTP.equals(apiRequest.getHttp_checked())) { transports.add(Constants.PROTOCOL_HTTP); } if (Constants.PROTOCOL_HTTPS.equals(apiRequest.getHttps_checked())) { transports.add(Constants.PROTOCOL_HTTPS); } body.setTransport(transports); body.isDefaultVersion(false); body.setCacheTimeout(100); ArrayList<String> gatewayEnvironments = new ArrayList<>(); gatewayEnvironments.add(apiRequest.getEnvironment()); body.setGatewayEnvironments(gatewayEnvironments); body.setOperations(apiRequest.getOperationsDTOS()); body.setMediationPolicies(apiRequest.getMediationPolicies()); body.setBusinessInformation(new APIBusinessInformationDTO()); body.setCorsConfiguration(new APICorsConfigurationDTO()); body.setTags(Arrays.asList(apiRequest.getTags().split(","))); body.setEndpointConfig(apiRequest.getEndpointConfig()); body.setSecurityScheme(apiRequest.getSecurityScheme()); List<String> tierList = new ArrayList<>(); tierList.add(Constants.TIERS_UNLIMITED); body.setPolicies(Arrays.asList(apiRequest.getTiersCollection().split(","))); body.isDefaultVersion(Boolean.valueOf(apiRequest.getDefault_version_checked())); APIDTO apidto; try { ApiResponse<APIDTO> httpInfo = apIsApi.apisPostWithHttpInfo(body, osVersion); Assert.assertEquals(201, httpInfo.getStatusCode()); apidto = httpInfo.getData(); } catch (ApiException e) { if (e.getResponseBody().contains("already exists")) { return null; } throw new ApiException(e); } return apidto; }