当前位置: 首页>>代码示例>>Java>>正文


Java Entity.entity方法代码示例

本文整理汇总了Java中javax.ws.rs.client.Entity.entity方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.entity方法的具体用法?Java Entity.entity怎么用?Java Entity.entity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.client.Entity的用法示例。


在下文中一共展示了Entity.entity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: submit

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
public PredictResponse submit() throws IOException {
  FormDataMultiPart formPart = new FormDataMultiPart();
  formPart.field("modelId", modelId);
  formPart.field("sampleLocation", sampleLocation);

  MediaType contentType = formPart.getMediaType();
  contentType = Boundary.addBoundary(contentType);
  Entity<FormDataMultiPart> entity = Entity.entity(formPart, contentType);

  Response response = client.target(EINSTEIN_VISION_URL + "/v1/vision/predict")
      .request()
      .header("Authorization", "Bearer " + getToken())
      .post(entity);

  if (!isSuccessful(response)) {
    throw new IOException("Error occurred while making prediction call " + response);
  }

  return readResponseAs(response, PredictResponse.class);
}
 
开发者ID:MetaMind,项目名称:quickstart,代码行数:21,代码来源:PredictRequest.java

示例2: testExecute_WithUpdateInspectionHook_ExpectStatusOk

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testExecute_WithUpdateInspectionHook_ExpectStatusOk() {
    // Assume.
    Response response = null;
    try {

        InspectionHookEntity inspectionHook = createInspectionHookEntity();

        Entity<InspectionHookEntity> entity = Entity.entity(inspectionHook, MediaType.APPLICATION_JSON);
        // Act.
        response = target("controller/1.2.3.0/inspectionHooks/HookId")
                .request()
                .header(this.AUTHORIZATION_HEADER, this.AUTHORIZATION_CREDS)
                .put(entity);

        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());

    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:27,代码来源:InspectionHookApisTest.java

示例3: testExecute_WithUpdateInspectionPort_ExpectStatusOk

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testExecute_WithUpdateInspectionPort_ExpectStatusOk() {
    // Assume.
    Response response = null;
    try {

        InspectionPortElement inspectionPort = createInspectionPortEntity();
        Entity<InspectionPortElement> entity = Entity.entity(inspectionPort, MediaType.APPLICATION_JSON);
        // Act.
        response = target("controller/1.2.3.0/inspectionPorts/InspPortId")
                .request()
                .header(this.AUTHORIZATION_HEADER, this.AUTHORIZATION_CREDS)
                .put(entity);

        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());

    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:26,代码来源:InspectionPortApisTest.java

示例4: testExecute_WithUpdateInspectionPort_ExpectErrorCode

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testExecute_WithUpdateInspectionPort_ExpectErrorCode() {
    // Assume.
    Response response = null;
    try {

        InspectionPortElement inspectionPort = createInspectionPortEntity();
        Entity<InspectionPortElement> entity = Entity.entity(inspectionPort, MediaType.APPLICATION_JSON);

        String badParam = "IdNotMatching";
        // Act.
        response = target("controller/1.2.3.0/inspectionPorts/" + badParam)
                .request()
                .header(this.AUTHORIZATION_HEADER, this.AUTHORIZATION_CREDS)
                .put(entity);
        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(500);

    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:27,代码来源:InspectionPortApisTest.java

示例5: addBook

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Before
public void addBook() throws Exception {
  Book book = new Book();
  book.setTitle("How to Win Friends & Influence People");
  book.setAuthor("Dale Carnegie");
  book.setIsbn("067142517X");
  book.setPages(299);
  book.setPublished(Instant.now());

  String username = "durimkryeziu";
  String password = "password";

  String encodedString = Base64.getEncoder()
      .encodeToString(String.format("%s:%s", username, password).getBytes());

  authHeaderValue = String.format("Basic %s", encodedString);

  Entity<Book> bookEntity = Entity.entity(book, MediaType.APPLICATION_JSON);
  Response response = target("books")
      .request(MediaType.APPLICATION_JSON)
      .header(HttpHeaders.AUTHORIZATION, authHeaderValue)
      .post(bookEntity);

  Book bookResponse = response.readEntity(Book.class);
  this.bookId = bookResponse.getId();
}
 
开发者ID:durimkryeziu,项目名称:jersey-2.x-webapp-for-servlet-container,代码行数:27,代码来源:BookResourceIntegrationTest.java

示例6: testExecute_WithPostPort_ExpectErrorCode

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testExecute_WithPostPort_ExpectErrorCode() {
    // Assume.
    Response response = null;
    try {
        PortEntity port = createPortEntity();

        Entity<PortEntity> portEntity = Entity.entity(port, MediaType.APPLICATION_JSON);

        String badParam = "IdNotMatching";
        // Act.
        response = target("controller/1.2.3.0/portElements/" + badParam)
                .request()
                .header(this.AUTHORIZATION_HEADER, this.AUTHORIZATION_CREDS)
                .post(portEntity);

        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(500);
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:27,代码来源:PortApisTest.java

示例7: testExecute_WithUpdatePort_ExpectStatusOk

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testExecute_WithUpdatePort_ExpectStatusOk() {
    // Assume.
    Response response = null;
    try {
        PortEntity port = createPortEntity();
        Entity<PortEntity> portEntity = Entity.entity(port, MediaType.APPLICATION_JSON);

        // Act.
        response = target("controller/1.2.3.0/portElements/ElementId")
                .request()
                .header(this.AUTHORIZATION_HEADER, this.AUTHORIZATION_CREDS)
                .put(portEntity);

        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());

    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:26,代码来源:PortApisTest.java

示例8: testExecute_WithUpdatePort_ExpectErrorCode

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testExecute_WithUpdatePort_ExpectErrorCode() {
    // Assume.
    Response response = null;
    try {
        PortEntity port = createPortEntity();
        Entity<PortEntity> portEntity = Entity.entity(port, MediaType.APPLICATION_JSON);

        String badParam = "IdNotMatching";
        // Act.
        response = target("controller/1.2.3.0/portElements/" + badParam)
                .request()
                .header(this.AUTHORIZATION_HEADER, this.AUTHORIZATION_CREDS)
                .put(portEntity);

        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(500);

    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:27,代码来源:PortApisTest.java

示例9: testPostAlarm_withGoodRequest_expectStatusAccepted

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testPostAlarm_withGoodRequest_expectStatusAccepted() {
    // Assume.
    Response response = null;
    try {
        AlarmDto alarm = getAlarmDto();

        Entity<AlarmDto> alarmEntity = Entity.entity(alarm, MediaType.APPLICATION_JSON);

        // Act.
        response = target("/api/server/v1/alarms")
                .request()
                .header(this.authorizationHeader, this.authorizationCreds)
                .post(alarmEntity);
        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(202);
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:25,代码来源:AlarmApisTest.java

示例10: testPutAlarm_withGoodRequest_expectStatusAccepted

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testPutAlarm_withGoodRequest_expectStatusAccepted() {
    // Assume.
    Response response = null;
    try {
        AlarmDto alarm = getAlarmDto();

        Entity<AlarmDto> alarmEntity = Entity.entity(alarm, MediaType.APPLICATION_JSON);

        // Act.
        response = target("/api/server/v1/alarms/2")
                .request()
                .header(this.authorizationHeader, this.authorizationCreds)
                .put(alarmEntity);
        response.close();

        // Assert.
        assertThat(response.getStatus()).isEqualTo(202);
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:25,代码来源:AlarmApisTest.java

示例11: getAccessToken

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
public Result<AccessTokenRepresentation> getAccessToken(ClientCredentials clientCredentials) {
	Entity<String> entity = Entity.entity("grant_type=client_credentials", MediaType.APPLICATION_FORM_URLENCODED);

	Response response = resource("/oauth/token").property(HTTP_AUTHENTICATION_BASIC_USERNAME, clientCredentials.getClientId()).property(HTTP_AUTHENTICATION_BASIC_PASSWORD, clientCredentials.getSecret()).post(entity);
	if (response.getStatus() == 200) {
		return Result.accept(response.getStatus(), response.readEntity(AccessTokenRepresentation.class));
	}

	return Result.reject(response.getStatus(), null, resolve(response));
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:11,代码来源:TokensClient.java

示例12: testMultipartOptionalWithoutFile

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testMultipartOptionalWithoutFile() {
    final String mockContent =
            "------WebKitFormBoundarycTqA2AimXQHBAJbZ\n" +
            "------WebKitFormBoundarycTqA2AimXQHBAJbZ";

    final Entity<String> entity = Entity.entity(mockContent, MediaType.MULTIPART_FORM_DATA_TYPE);

    assertEquals("null", target("/multipart-optional").request().post(entity, String.class));
}
 
开发者ID:minijax,项目名称:minijax,代码行数:11,代码来源:FormParamTest.java

示例13: testDeflateIngest

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void testDeflateIngest() {
  byte[] compressed = compress(INGEST_DATA, DeflaterOutputStream.class);
  Entity<byte[]> entity = Entity.entity(
      compressed, compressedVariant(MediaType.TEXT_PLAIN_TYPE, "deflate"));
  checkResponse(target("/ingest").request().post(entity));
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:8,代码来源:IngestTest.java

示例14: getEntity

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Override
public Entity getEntity(MultiValuedMap fields, String mediaType) {
    MultivaluedHashMap<String, Object> map = new MultivaluedHashMap<>();
    for (Entry<String, List> entry : fields.entrySet()) {
        map.put(entry.getKey(), entry.getValue());
    }
    return Entity.entity(map, mediaType);
}
 
开发者ID:intuit,项目名称:karate,代码行数:9,代码来源:JerseyHttpClient.java

示例15: pushAllTicket

import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
/**
 * Push ticket to web app
 * @param actionEvent
 */
@FXML
protected void pushAllTicket(ActionEvent actionEvent) {

    try{
        for(int i=0; i<ticket.size(); i++) {
            if (ticket.get(i).getBilled() == "Oui")
                ticket.get(i).setBilled("1");
            else
                ticket.get(i).setBilled("0");


            Entity<Tickets> ticketEntity = Entity.entity(ticket.get(i), MediaType.APPLICATION_XML_TYPE);
            Response response = client.target(REST_ROOT_URL).path("ticket").path("pushticket").request().post(ticketEntity);
        }
        ticketItems.removeAll(ticket);
        ticket.removeAll(ticket);


        ticketTableView.refresh();

        clearAll.setDisable(true);
        pushAll.setDisable(true);
    }catch(Exception e){
        e.printStackTrace();
    }
}
 
开发者ID:atecna,项目名称:Atecmer,代码行数:31,代码来源:MyFrame.java


注:本文中的javax.ws.rs.client.Entity.entity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。