How to use getHeaders method of com.testsigma.service.BugZillaService class

Best Testsigma code snippet using com.testsigma.service.BugZillaService.getHeaders

Source:BugZillaService.java Github

copy

Full Screen

...40 payload.put("version", mapping.getFields().get("version").toString());41 payload.put("product", mapping.getFields().get("project").toString());42 payload.put("op_sys", "All");43 payload.put("rep_platform", "All");44 HttpResponse<JsonNode> response = httpClient.post(integrations.getUrl() + "/rest/bug?api_key=" + integrations.getToken(), getHeaders(), payload, new TypeReference<JsonNode>() {45 });46 if (response.getStatusCode() != HttpStatus.SC_OK) {47 log.error(response.getResponseText());48 throw new TestsigmaException("Problem while creating BugZilla issue with ::" + mapping.getFields());49 }50 mapping.setExternalId(String.valueOf(response.getResponseEntity().get("id")));51 return mapping;52 }53 public TestCaseResultExternalMapping link(TestCaseResultExternalMapping mapping) throws TestsigmaException {54 HashMap<String, String> payload = new HashMap<>();55 payload.put("comment", "Linked to testsigma results [" + config.getServerUrl() + "/ui/td/test_case_results/" + mapping.getTestCaseResultId() + "] :: " + mapping.getTestCaseResult().getTestCase().getName());56 HttpResponse<String> response = httpClient.post(integrations.getUrl() + "/rest/bug/" + mapping.getExternalId() + "/comment?api_key=" + this.integrations.getToken(), getHeaders(), payload, new TypeReference<String>() {57 });58 if (response.getStatusCode() != HttpStatus.SC_CREATED) {59 log.error(response.getResponseText());60 throw new TestsigmaException("Problem while Linking BugZilla issue with ::" + mapping.getExternalId());61 }62 return mapping;63 }64 public TestCaseResultExternalMapping unlink(TestCaseResultExternalMapping mapping) throws TestsigmaException {65 HashMap<String, String> payload = new HashMap<>();66 payload.put("comment", "Unlinked from testsigma results [" + config.getServerUrl() + "/ui/td/test_case_results/" + mapping.getTestCaseResultId() + "] :: " + mapping.getTestCaseResult().getTestCase().getName());67 HttpResponse<String> response = httpClient.post(integrations.getUrl() + "/rest/bug/" + mapping.getExternalId() + "/comment?api_key=" + this.integrations.getToken(), getHeaders(), payload, new TypeReference<String>() {68 });69 if (response.getStatusCode() != HttpStatus.SC_CREATED) {70 log.error(response.getResponseText());71 throw new TestsigmaException("Problem while unLinking BugZilla issue with ::" + mapping.getExternalId());72 }73 return mapping;74 }75 public JsonNode getIssuesList(String project, String issueType, String version) throws TestsigmaException {76 HttpResponse<JsonNode> response = httpClient.get(integrations.getUrl() + "/rest/bug?project=" + project + "&component=" + issueType + "&version=" + version, getHeaders(), new TypeReference<JsonNode>() {77 });78 return response.getResponseEntity();79 }80 public JsonNode getIssue(Long issueId) throws TestsigmaException {81 HttpResponse<JsonNode> response = httpClient.get(integrations.getUrl() + "/rest/bug/" + issueId, getHeaders(), new TypeReference<JsonNode>() {82 });83 return response.getResponseEntity();84 }85 //projects86 public JsonNode projects() throws TestsigmaException {87 HttpResponse<JsonNode> response = httpClient.get(integrations.getUrl() + "/rest/product_accessible?api_key=" + integrations.getToken(), getHeaders(), new TypeReference<JsonNode>() {88 });89 JsonNode projectIds = response.getResponseEntity().get("ids");90 StringBuilder result = new StringBuilder();91 projectIds.forEach(id -> {92 result.append("ids=");93 result.append(id.toString());94 result.append("&");95 });96 result.deleteCharAt(result.length() - 1);97 response = httpClient.get(integrations.getUrl() + "/rest/product?api_key=" + integrations.getToken() + "&" + result, getHeaders(), new TypeReference<JsonNode>() {98 });99 return response.getResponseEntity();100 }101 public JsonNode testIntegration(IntegrationsRequest testAuth) throws TestsigmaException {102 HttpResponse<JsonNode> response = httpClient.get(testAuth.getUrl()103 + "/rest/product_accessible?api_key=" + testAuth.getToken(), getHeaders(), new TypeReference<JsonNode>() {104 });105 JsonNodeFactory jnf = JsonNodeFactory.instance;106 ObjectNode status = jnf.objectNode();107 status.put("status_code", response.getStatusCode());108 status.put("status_message", response.getStatusMessage());109 return status;110 }111 private List<Header> getHeaders() {112 Header contentType = new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json");113 return Lists.newArrayList(contentType);114 }115}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testsigma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful