Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #35 from sbtqa/make-apientry-protected
Browse files Browse the repository at this point in the history
Make all private method and fields as protected
  • Loading branch information
kosteman authored Apr 23, 2018
2 parents bff718b + e97d821 commit 57c6e6f
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/main/java/ru/sbtqa/tag/apifactory/ApiEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public abstract class ApiEntry {

private static final Logger LOG = LoggerFactory.getLogger(ApiEntry.class);
protected static final Logger LOG = LoggerFactory.getLogger(ApiEntry.class);

private String requestPath = this.getClass().getAnnotation(ApiAction.class).path();
private final Map<String, String> headers = new HashMap<>();
Expand Down Expand Up @@ -80,7 +80,7 @@ public void setParamValueByTitle(String title, String value) throws ApiException
* @throws ru.sbtqa.tag.apifactory.exception.ApiException if parameter with
* name doesn't exists or not available
*/
private void setParamValueByName(String name, Object value) throws ApiException {
protected void setParamValueByName(String name, Object value) throws ApiException {
List<Field> fieldList = FieldUtilsExt.getDeclaredFieldsWithInheritance(this.getClass());
for (Field field : fieldList) {
if (name.equals(field.getName())) {
Expand Down Expand Up @@ -348,7 +348,7 @@ public void applyParametersAnnotation() throws ApiException {
* @throws ru.sbtqa.tag.apifactory.exception.ApiException if one of headers
* is not available
*/
private void setHeaders() throws ApiException {
protected void setHeaders() throws ApiException {
List<Field> fieldList = FieldUtilsExt.getDeclaredFieldsWithInheritance(this.getClass());
for (Field field : fieldList) {
for (Annotation annotation : field.getAnnotations()) {
Expand All @@ -370,7 +370,7 @@ private void setHeaders() throws ApiException {
* @return partUrl withParams
* @throws ru.sbtqa.tag.apifactory.exception.ApiException
*/
private String getFullUrl(String url) throws ApiException {
protected String getFullUrl(String url) throws ApiException {
List<Field> fieldList = FieldUtilsExt.getDeclaredFieldsWithInheritance(this.getClass());
String urlParamString = "";
for (Field field : fieldList) {
Expand Down Expand Up @@ -446,7 +446,7 @@ public void setBody() throws ApiException {
}

@SuppressWarnings("ThrowableResultIgnored")
private void setDependentResponseParameters() throws ApiException {
protected void setDependentResponseParameters() throws ApiException {
List<Field> fieldList = FieldUtilsExt.getDeclaredFieldsWithInheritance(this.getClass());
for (Field field : fieldList) {
field.setAccessible(true);
Expand Down Expand Up @@ -514,7 +514,7 @@ private void setDependentResponseParameters() throws ApiException {
}
}

private Map<String, Object> sortByKeyLength(Map<String, Object> map) {
protected Map<String, Object> sortByKeyLength(Map<String, Object> map) {
Map<String, Object> treeMap = new TreeMap<>(
new Comparator<String>() {
@Override
Expand Down Expand Up @@ -542,6 +542,15 @@ public Map<String, String> getHeaders() {
return headers;
}

/**
* Add header to headers map
* @param key
* @param value
*/
public void addHeader(String key, String value) {
headers.put(key, value);
}

/**
* Get parameters
*
Expand All @@ -551,6 +560,15 @@ public Map<String, Object> getParameters() {
return parameters;
}

/**
* Add parameter to parameters map
* @param key
* @param value
*/
public void addParameter(String key, Object value) {
parameters.put(key, value);
}

/**
* Get request body
*
Expand Down Expand Up @@ -594,7 +612,14 @@ public void setTemplate(String template) {
*/
public String getActionPath() {
return requestPath;
}

/**
* Set action path
* @param path
*/
public void setActionPath(String path) {
requestPath = path;
}

/**
Expand Down

0 comments on commit 57c6e6f

Please sign in to comment.