Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class HttpRepository<THttpEntity extends HttpEntity> implements
protected final HttpContext repositoryContext;
private final Class<THttpEntity> entityType;
private final ObjectConverter objectConverter;
private HttpContext requestContext;
protected HttpContext requestContext;

protected HttpRepository(Class<THttpEntity> entityType, ObjectConverter objectConverter, Supplier<HttpContext> repositoryContext) {
this.entityType = entityType;
Expand Down Expand Up @@ -158,7 +158,7 @@ private RequestSpecification client() {
return RestAssured.given().spec(requestContext.requestSpecification());
}

private <R> R deserializeInternal(HttpResponse response, DeserializationMode mode) {
protected <R> R deserializeInternal(HttpResponse response, DeserializationMode mode) {
try {
if (mode == DeserializationMode.LIST) {
List<THttpEntity> entities = objectConverter.fromStringToList(response.getBody(), entityType);
Expand All @@ -174,7 +174,7 @@ private <R> R deserializeInternal(HttpResponse response, DeserializationMode mod
}
}

private Response broadcastRequest(Supplier<Response> responseSupplier) {
protected Response broadcastRequest(Supplier<Response> responseSupplier) {
try {
SENDING_REQUEST.broadcast(new HttpRequestEventArgs(requestContext));
Response response = responseSupplier.get();
Expand Down
58 changes: 58 additions & 0 deletions bellatrix.servicenow/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>solutions.bellatrix</groupId>
<artifactId>bellatrix</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>bellatrix.servicenow</artifactId>

<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bellatrix.framework.version>1.0</bellatrix.framework.version>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>solutions.bellatrix</groupId>
<artifactId>bellatrix.core</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>solutions.bellatrix</groupId>
<artifactId>bellatrix.web</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>solutions.bellatrix</groupId>
<artifactId>bellatrix.api</artifactId>
<version>${bellatrix.framework.version}</version>
</dependency>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>solutions.bellatrix</groupId>
<artifactId>bellatrix.data</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package solutions.bellatrix.servicenow.baseTest;


import solutions.bellatrix.servicenow.listeners.AutoWaitListener;
import solutions.bellatrix.servicenow.pages.serviceNowPage.ServiceNowPage;
import solutions.bellatrix.servicenow.pages.serviceNowTableViewPage.ServiceNowTableViewPage;
import solutions.bellatrix.servicenow.plugins.authentication.AuthenticationPlugin;
import solutions.bellatrix.servicenow.plugins.fileuploads.FileUploadPlugin;
import solutions.bellatrix.core.plugins.junit.BaseTest;
import solutions.bellatrix.web.infrastructure.BrowserLifecyclePlugin;
import solutions.bellatrix.web.infrastructure.LogLifecyclePlugin;
import solutions.bellatrix.web.services.App;

public class ServiceNowBaseTest extends BaseTest {
protected ServiceNowPage serviceNowPage;
protected ServiceNowTableViewPage serviceNowTableViewPage;

protected App app() {
return new App();
}

@Override
protected void configure() {
addPlugin(FileUploadPlugin.class);
addPlugin(LogLifecyclePlugin.class);
addPlugin(BrowserLifecyclePlugin.class);
addPlugin(AuthenticationPlugin.class);
addListener(AutoWaitListener.class);
}

@Override
protected void beforeEach() throws Exception {
super.beforeEach();
serviceNowPage = app().createPage(ServiceNowPage.class);
serviceNowTableViewPage = app().createPage(ServiceNowTableViewPage.class);
}

@Override
protected void afterEach() {
super.afterEach();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package solutions.bellatrix.servicenow.components.enums;

public enum InputRole {
COMBOBOX("combobox"),
SPINBUTTON("spinbutton"),
TEXTBOX("textbox");

private final String role;

InputRole(String role) {
this.role = role;
}

public String getRole() {
return role;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package solutions.bellatrix.servicenow.components.enums;

public enum OperationsAttributes {
EQUALS("Equals", "=", "Equals"),
DOES_NOT_EQUAL("Does not equal", "!=", "DoesNotEqual"),
IS_LESS_THAN("Is less than", "<", "IsLessThan"),
IS_GREATER_THAN("Is greater than", ">", "IsGreaterThan"),
IS_LESS_THAN_OR_EQUAL_TO("Is less than or equal to", "<=", "IsLessThanOrEqualTo"),
IS_GREATER_THAN_OR_EQUAL_TO("Is greater than or equal to", ">=", "IsGreaterThanOrEqualTo"),
IS_BLANK("Is blank", "", "IsBlank"),
IS_NOT_BLANK("Is not blank", "", "IsNotBlank"),
IS_BETWEEN("Is between", "", "IsBetween"),
CONTAINS("Contains", "", "Contains"),
DOES_NOT_CONTAIN("Does not contain", "", "DoesNotContain"),
STARTS_WITH("Starts with", "", "StartsWith"),
ENDS_WITH("Ends with", "", "EndsWith");

private final String value;
private final String sign;
private final String nameMethod;

OperationsAttributes(String value, String sign, String nameMethod) {
this.value = value;
this.sign = sign;
this.nameMethod = nameMethod;
}

public String getValue() {
return this.value;
}

public String getSign() {
return sign;
}

public String getNameMethod() {
return nameMethod;
}

@Override
public String toString() {
return this.value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package solutions.bellatrix.servicenow.components.enums;

public enum SnComponentType {
CHOICE("choice"),
DATE("date"),
DATE_TIME("date_time"),
DOCUMENT_ID("document_id"),
REFERENCE("reference"),
STRING("string"),
TABLE_NAME("table_name"),
PICK_LIST("pick_list"),
BOOLEAN("boolean"),
FLOAT("float"),
INTEGER("integer"),
PERCENT_COMPLETE("percent_complete"),
CURRENCY_2("currency2"),
GLIDE_LIST("glide_list"),
GLIDE_TIME("glide_time"),
DURATION("glide_duration"),
HTML("html"),
CURRENCY("currency2"),
JOURNAL_INPUT("journal_input"),
CURRENCY2("currency2"),
FIELD_NAME("field_name"),
SN_CONDITION_ROW("condition_row"),
SEARCH("search");

private final String componentType;

SnComponentType(String componentType) {
this.componentType = componentType;
}

@Override
public String toString() {
return componentType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package solutions.bellatrix.servicenow.components.enums;

public enum StyleAlignment {
LEFT("left"),
RIGHT("right"),
CENTER("center");

private final String value;

StyleAlignment(String label) {
this.value = label;
}

public String getValue() {
return "text-align: " + this.value + ";";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package solutions.bellatrix.servicenow.components.enums;

public enum UibComponentType {
CHOICE("choice"),
DATE("date"),
DATE_TIME("date_time"),
DOCUMENT_ID("document_id"),
REFERENCE("reference"),
STRING("string"),
TEXTAREA("textarea"),
TABLE_NAME("table_name"),
PICK_LIST("pick_list"),
BOOLEAN("boolean"),
FLOAT("float"),
INTEGER("integer"),
PERCENT_COMPLETE("percent_complete"),
CURRENCY_2("currency2"),
GLIDE_LIST("glide_list"),
GLIDE_TIME("glide_time"),
DURATION("glide_duration"),
HTML("html"),
CURRENCY("currency2"),
JOURNAL_INPUT("journal_input"),
CURRENCY2("currency2"),
FIELD_NAME("field_name"),
SN_CONDITION_ROW("condition_row");

private final String componentType;

UibComponentType(String componentType) {
this.componentType = componentType;
}

@Override
public String toString() {
return componentType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package solutions.bellatrix.servicenow.components.models;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
public class ComponentFilterGroupModel {
@SerializedName("operation")
private String operation;
@SerializedName("condition")
private String condition;
@SerializedName("operationType")
private String operationType;
@SerializedName("filterValue")
private String filterValue;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package solutions.bellatrix.servicenow.components.models;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
public class ComponentFilterModel {
@SerializedName("groupOperation")
private String groupOperation;
@SerializedName("groupedFilters")
private ComponentFilterGroupModel[] vulnerability;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package solutions.bellatrix.servicenow.components.models;

import lombok.Data;
import lombok.experimental.SuperBuilder;
import solutions.bellatrix.servicenow.components.enums.OperationsAttributes;

import java.util.List;

@Data
@SuperBuilder
public class GridFilter {
private String gridColumnHeader;
private OperationsAttributes operation;
private List<String> conditionValue;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package solutions.bellatrix.servicenow.components.models;

import lombok.Data;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.NotImplementedException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;

@Data
@SuperBuilder
public class ServiceNowForm {
public String getNumber() {
throw new NotImplementedException("Implement in child classes");
}

public ServiceNowForm() {
}

public void setNumber(String number) {
}

public <Form extends ServiceNowForm> List<Field> getNotNullFields() {
return Arrays.stream(this.getClass().getDeclaredFields()).filter(f -> {
try {
f.setAccessible(true);
return f.get(this) != null;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}).toList();
}
}
Loading