List of usage examples for org.springframework.http HttpHeaders AUTHORIZATION
String AUTHORIZATION
To view the source code for org.springframework.http HttpHeaders AUTHORIZATION.
Click Source Link
From source file:org.openlmis.fulfillment.web.OrderFileTemplateControllerIntegrationTest.java
@Test public void shouldReturnOrderFileTemplate() { given(orderFileTemplateService.getOrderFileTemplate()).willReturn(orderFileTemplate); OrderFileTemplateDto result = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(MediaType.APPLICATION_JSON_VALUE).when().get(RESOURCE_URL).then().statusCode(200) .extract().as(OrderFileTemplateDto.class); assertEquals(orderFileTemplate.getId(), result.getId()); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.BaseTransferPropertiesControllerIntegrationTest.java
@Test public void shouldGetChosenProperties() { // given/* ww w . ja va 2s .co m*/ T properties = generateProperties(); given(transferPropertiesRepository.findOne(properties.getId())).willReturn(properties); // when TransferPropertiesDto response = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(MediaType.APPLICATION_JSON_VALUE).pathParam("id", properties.getId()).when() .get(ID_URL).then().statusCode(200).extract().as(TransferPropertiesDto.class); // then assertTransferProperties((T) TransferPropertiesFactory.newInstance(response)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.OrderNumberConfigurationControllerIntegrationTest.java
@Test public void shouldReturn403WhenUserHasNoRightsToViewOrderNumberConfiguration() { denyUserAllRights();//from w ww . jav a 2s . co m restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(MediaType.APPLICATION_JSON_VALUE).when().get(RESOURCE_URL).then().statusCode(403); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.ShipmentDraftControllerIntegrationTest.java
@Test public void shouldReturnBadRequestIfShipmentDraftOrderIsNotGiven() { shipmentDraftDto.setOrder((OrderObjectReferenceDto) null); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON_VALUE) .body(shipmentDraftDto).when().post(RESOURCE_URL).then().statusCode(400) .body(MESSAGE_KEY, equalTo(MessageKeys.SHIPMENT_ORDERLESS_NOT_SUPPORTED)); verify(shipmentDraftRepository, never()).save(any(ShipmentDraft.class)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.responseChecks()); }
From source file:org.openlmis.fulfillment.web.TemplateControllerIntegrationTest.java
@Test public void shouldNotGetNonexistentTemplate() { given(templateRepository.findOne(template.getId())).willReturn(null); given(templateRepository.exists(template.getId())).willReturn(false); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(MediaType.APPLICATION_JSON_VALUE).pathParam("id", template.getId()).when().get(ID_URL) .then().statusCode(404);/*from w w w. ja v a 2 s .c om*/ assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.trustedanalytics.metadata.parser.MetadataParserIT.java
private ResponseEntity<String> postRequest(MetadataParseRequest request) { testRestTemplate.setInterceptors(Collections .singletonList(new HeaderAddingHttpInterceptor(HttpHeaders.AUTHORIZATION, "bearer " + TOKEN))); return testRestTemplate.postForEntity(baseUrl + "/rest/metadata", request, String.class); }
From source file:org.openlmis.fulfillment.web.OrderFileTemplateControllerIntegrationTest.java
@Test public void shouldNotReturnOrderFileTemplateIfItDoesNotExist() { given(orderFileTemplateService.getOrderFileTemplate()).willReturn(null); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(MediaType.APPLICATION_JSON_VALUE).when().get(RESOURCE_URL).then().statusCode(404); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.BaseTransferPropertiesControllerIntegrationTest.java
@Test public void shouldNotGetNonexistentProperties() { // given/* w w w . j a v a 2 s.co m*/ T properties = generateProperties(); given(transferPropertiesRepository.findOne(properties.getId())).willReturn(null); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(MediaType.APPLICATION_JSON_VALUE).pathParam("id", properties.getId()).when() .get(ID_URL).then().statusCode(404); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.trustedanalytics.metadata.parser.MetadataParserIT.java
private ResponseEntity<String> postRequest(MetadataParseRequest request, String endpoint) { testRestTemplate.setInterceptors(Collections .singletonList(new HeaderAddingHttpInterceptor(HttpHeaders.AUTHORIZATION, "bearer " + TOKEN))); return testRestTemplate.postForEntity(baseUrl + endpoint, request, String.class); }
From source file:org.openlmis.fulfillment.web.ShipmentControllerIntegrationTest.java
@Test public void shouldReturnBadRequestIfShipmentOrderIsNotGiven() { shipmentDto.setOrder((OrderObjectReferenceDto) null); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON_VALUE) .body(shipmentDto).when().post(RESOURCE_URL).then().statusCode(400) .body(MESSAGE_KEY, equalTo(MessageKeys.SHIPMENT_ORDERLESS_NOT_SUPPORTED)); verify(shipmentRepository, never()).save(any(Shipment.class)); verify(stockEventBuilder, never()).fromShipment(any(Shipment.class)); verify(stockEventService, never()).submit(any(StockEventDto.class)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.responseChecks()); }