Commit e731fabb authored by Aman Verma's avatar Aman Verma
Browse files

resolving merge conflict

parents 0a32d7f2 305a1a16
Pipeline #60451 failed with stages
in 82 minutes and 36 seconds
package org.opengroup.osdu.schema.stepdefs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.google.inject.Inject;
import io.cucumber.java8.En;
import org.opengroup.osdu.schema.constants.TestConstants;
import org.opengroup.osdu.schema.stepdefs.model.HttpRequest;
import org.opengroup.osdu.schema.stepdefs.model.HttpResponse;
import org.opengroup.osdu.schema.stepdefs.model.SchemaServiceScope;
import org.opengroup.osdu.schema.util.HttpClientFactory;
import org.opengroup.osdu.schema.util.VersionInfoUtils;
public class InfoStepDef_GET implements En {
@Inject
private SchemaServiceScope context;
private VersionInfoUtils versionInfoUtil = new VersionInfoUtils();
public InfoStepDef_GET() {
Given("I send get request to version info endpoint", () -> {
HttpRequest httpRequest = HttpRequest.builder()
.url(TestConstants.HOST + TestConstants.GET_INFO_ENDPOINT)
.httpMethod(HttpRequest.GET)
.build();
HttpResponse response = HttpClientFactory.getInstance().send(httpRequest);
this.context.setHttpResponse(response);
});
Then("service should respond back with version info in response", () -> {
assertEquals(200, this.context.getHttpResponse().getCode());
VersionInfoUtils.VersionInfo responseObject = this.versionInfoUtil
.getVersionInfoFromResponse(this.context.getHttpResponse());
assertNotNull(responseObject.groupId);
assertNotNull(responseObject.artifactId);
assertNotNull(responseObject.version);
assertNotNull(responseObject.buildTime);
assertNotNull(responseObject.branch);
assertNotNull(responseObject.commitId);
assertNotNull(responseObject.commitMessage);
});
}
}
package org.opengroup.osdu.schema.util;
import com.google.gson.Gson;
import org.opengroup.osdu.schema.stepdefs.model.HttpResponse;
public class VersionInfoUtils {
public VersionInfo getVersionInfoFromResponse(HttpResponse response) {
String json = response.getBody();
Gson gson = new Gson();
return gson.fromJson(json, VersionInfo.class);
}
public class VersionInfo {
public String groupId;
public String artifactId;
public String version;
public String buildTime;
public String branch;
public String commitId;
public String commitMessage;
}
}
Feature: To verify version info endpoint content
@SchemaServiceAzure
Scenario: Verify version info endpoint content
Given I send get request to version info endpoint
Then service should respond back with version info in response
......@@ -7,6 +7,7 @@ public class TestConstants {
public static final String GET_LIST_ENDPOINT = "/api/schema-service/v1/schema";
public static final String GET_ENDPOINT = "/api/schema-service/v1/schema/";
public static final String GET_FLATTENED_ENDPOINT = "/api/schema-service/v1/schema/{id}/IndexerSchemaV1";
public static final String GET_INFO_ENDPOINT = "/api/schema-service/v1/info";
//public static final String HOST = "http://localhost:8080";
public static final String INTERNAL_SERVER_ERROR = "internal server error";
public static final String INTERNAL = "INTERNAL";
......
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opengroup.osdu.schema.stepdefs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.google.inject.Inject;
import io.cucumber.java8.En;
import org.opengroup.osdu.schema.constants.TestConstants;
import org.opengroup.osdu.schema.stepdefs.model.HttpRequest;
import org.opengroup.osdu.schema.stepdefs.model.HttpResponse;
import org.opengroup.osdu.schema.stepdefs.model.SchemaServiceScope;
import org.opengroup.osdu.schema.util.HttpClientFactory;
import org.opengroup.osdu.schema.util.VersionInfoUtils;
public class InfoStepDef_GET implements En {
@Inject
private SchemaServiceScope context;
private VersionInfoUtils versionInfoUtil = new VersionInfoUtils();
public InfoStepDef_GET() {
Given("I send get request to version info endpoint", () -> {
HttpRequest httpRequest = HttpRequest.builder()
.url(TestConstants.HOST + TestConstants.GET_INFO_ENDPOINT)
.httpMethod(HttpRequest.GET)
.build();
HttpResponse response = HttpClientFactory.getInstance().send(httpRequest);
this.context.setHttpResponse(response);
});
Then("service should respond back with version info in response", () -> {
assertEquals(200, this.context.getHttpResponse().getCode());
VersionInfoUtils.VersionInfo responseObject = this.versionInfoUtil
.getVersionInfoFromResponse(this.context.getHttpResponse());
assertNotNull(responseObject.groupId);
assertNotNull(responseObject.artifactId);
assertNotNull(responseObject.version);
assertNotNull(responseObject.buildTime);
assertNotNull(responseObject.branch);
assertNotNull(responseObject.commitId);
assertNotNull(responseObject.commitMessage);
});
}
}
/*
* Copyright 2021 Google LLC
* Copyright 2021 EPAM Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opengroup.osdu.schema.util;
import com.google.gson.Gson;
import org.opengroup.osdu.schema.stepdefs.model.HttpResponse;
public class VersionInfoUtils {
public VersionInfo getVersionInfoFromResponse(HttpResponse response) {
String json = response.getBody();
Gson gson = new Gson();
return gson.fromJson(json, VersionInfo.class);
}
public class VersionInfo {
public String groupId;
public String artifactId;
public String version;
public String buildTime;
public String branch;
public String commitId;
public String commitMessage;
}
}
Feature: To verify version info endpoint content
@SchemaService
Scenario: Verify version info endpoint content
Given I send get request to version info endpoint
Then service should respond back with version info in response
Supports Markdown
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