Search in sources :

Example 1 with ResourceVariable

use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.

the class ResourceVariablesServiceIT method testUpdateVariable.

@Test
public void testUpdateVariable() {
    ResourceVariable variable = createVariable("key", "value", false);
    variable.setKey("key2");
    variable.setValue("vabcdsaddsa");
    Entity entity = Entity.json(variable);
    Response response = client.target(variablesUrl).path(variable.getId()).request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    ResourceVariable returnedVariable = response.readEntity(ResourceVariable.class);
    assertVariables(variable, returnedVariable, false);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) ResourceVariable(io.lumeer.api.model.ResourceVariable) Test(org.junit.Test)

Example 2 with ResourceVariable

use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.

the class ResourceVariablesServiceIT method testUpdateBadRequestVariable.

@Test
public void testUpdateBadRequestVariable() {
    ResourceVariable variable = createVariable("key", "value", false);
    variable.setOrganizationId("xyzyzyzz");
    Entity entity = Entity.json(variable);
    Response response = client.target(variablesUrl).path(variable.getId()).request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) ResourceVariable(io.lumeer.api.model.ResourceVariable) Test(org.junit.Test)

Example 3 with ResourceVariable

use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.

the class ResourceVariablesServiceIT method testCreateVariable.

@Test
public void testCreateVariable() {
    ResourceVariable variable = prepareVariable("key", "value", false);
    Entity entity = Entity.json(variable);
    Response response = client.target(variablesUrl).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    ResourceVariable returnedVariable = response.readEntity(ResourceVariable.class);
    assertVariables(variable, returnedVariable, false);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) ResourceVariable(io.lumeer.api.model.ResourceVariable) Test(org.junit.Test)

Example 4 with ResourceVariable

use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.

the class ResourceVariablesServiceIT method testGetSecureVariables.

@Test
public void testGetSecureVariables() {
    createVariable("k1", "dsdad", true);
    createVariable("k2", "vadaslue", false);
    createVariable("k3", "dsa", true);
    createVariable("k4", "vadsadsalue", false);
    createVariable("k5", "dasdsadsa", true);
    Response response = client.target(variablesUrl).path("projects").path(projectId).request(MediaType.APPLICATION_JSON).buildGet().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    List<ResourceVariable> variables = response.readEntity(new GenericType<List<ResourceVariable>>() {
    });
    variables.forEach(variable -> {
        if (variable.getSecure()) {
            assertThat(variable.getKey()).isIn("k1", "k3", "k5");
            assertThat(variable.getValue()).isNull();
        } else {
            assertThat(variable.getKey()).isIn("k2", "k4");
            assertThat(variable.getValue()).isNotNull();
        }
    });
}
Also used : Response(javax.ws.rs.core.Response) ResourceVariable(io.lumeer.api.model.ResourceVariable) List(java.util.List) Test(org.junit.Test)

Example 5 with ResourceVariable

use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.

the class ResourceVariablesServiceIT method testGetVariable.

@Test
public void testGetVariable() {
    final ResourceVariable variable = createVariable("key", "value", false);
    Response response = client.target(variablesUrl).path(variable.getId()).request(MediaType.APPLICATION_JSON).buildGet().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    ResourceVariable returnedVariable = response.readEntity(ResourceVariable.class);
    assertVariables(variable, returnedVariable, false);
}
Also used : Response(javax.ws.rs.core.Response) ResourceVariable(io.lumeer.api.model.ResourceVariable) Test(org.junit.Test)

Aggregations

ResourceVariable (io.lumeer.api.model.ResourceVariable)15 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)6 ResourceType (io.lumeer.api.model.ResourceType)3 Entity (javax.ws.rs.client.Entity)3 AppId (io.lumeer.api.model.AppId)2 Collection (io.lumeer.api.model.Collection)2 DashboardData (io.lumeer.api.model.DashboardData)2 Document (io.lumeer.api.model.Document)2 Group (io.lumeer.api.model.Group)2 LinkInstance (io.lumeer.api.model.LinkInstance)2 LinkType (io.lumeer.api.model.LinkType)2 Organization (io.lumeer.api.model.Organization)2 Permissions (io.lumeer.api.model.Permissions)2 Project (io.lumeer.api.model.Project)2 ResourceComment (io.lumeer.api.model.ResourceComment)2 RoleType (io.lumeer.api.model.RoleType)2 RolesDifference (io.lumeer.api.model.RolesDifference)2 SelectionList (io.lumeer.api.model.SelectionList)2 Sequence (io.lumeer.api.model.Sequence)2