Commit 75a989b7 authored by Sheng Wang's avatar Sheng Wang
Browse files

log response status for EntityUtil, LegalTagUntils and SchemaUtil

parent 18f9166b
Pipeline #24223 failed with stages
in 12 minutes and 22 seconds
......@@ -30,6 +30,7 @@ public class EntityUtil {
String path = String.format("storage/v1/%s/", type.toLowerCase());
Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), token);
ClientResponse response = TestUtils.send(getEntityUrl(), path, "PUT", headers, body, "");
System.out.println(String.format("response status: %d %s", response.getStatus(), response.getStatusInfo().getReasonPhrase()));
Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus());
Thread.sleep(100);
System.out.println(String.format("created entity: %s", id));
......
......@@ -37,7 +37,7 @@ public class LegalTagUtils {
String body = getBody(countryOfOrigin, name, expDate, dataType);
ClientResponse response = TestUtils.send(getLegalUrl(), "legaltags", "POST", HeaderUtils.getHeaders(TenantUtils.getTenantName(), token), body,
"");
System.out.println(String.format("response status: %d %s", response.getStatus(), response.getStatusInfo().getReasonPhrase()));
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
Thread.sleep(100);
return response;
......@@ -45,6 +45,7 @@ public class LegalTagUtils {
public static ClientResponse delete(String legalTagName, String token) throws Exception {
ClientResponse response = TestUtils.send(getLegalUrl(), "legaltags/" + legalTagName, "DELETE", HeaderUtils.getHeaders(TenantUtils.getTenantName(), token), "", "");
System.out.println(String.format("response status: %d %s", response.getStatus(), response.getStatusInfo().getReasonPhrase()));
System.out.println(String.format("deleted legal tag: %s", legalTagName));
return response;
}
......
......@@ -14,19 +14,22 @@
package org.opengroup.osdu.wd.test.core.util;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.sun.jersey.api.client.ClientResponse;
import org.apache.http.HttpStatus;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class SchemaUtil {
public static ClientResponse create(String body, String token) throws Exception {
ClientResponse response = TestUtils.send(getSchemaUrl(), "schema", "PUT", HeaderUtils.getHeaders(TenantUtils.getTenantName(), token), body,"");
assertEquals(HttpStatus.SC_OK, response.getStatus());
System.out.println(String.format("response status: %d %s", response.getStatus(), response.getStatusInfo().getReasonPhrase()));
assertTrue((response.getStatus() == HttpStatus.SC_OK) || (response.getStatus() == HttpStatus.SC_CREATED));
Thread.sleep(100);
System.out.println("created schema.");
SchemaMock schema = getSchema(response);
System.out.println(String.format("created schema %s.", schema.schemaIdentity.id));
return response;
}
......@@ -239,4 +242,18 @@ public class SchemaUtil {
obj.add("items", items);
return obj;
}
private static SchemaMock getSchema(ClientResponse response) {
Gson gson = new Gson();
SchemaMock body = gson.fromJson(response.getEntity(String.class), SchemaMock.class);
return body ;
}
public class SchemaMock {
public schemaIdentityMock schemaIdentity;
}
public class schemaIdentityMock {
public String id;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment