Search in sources :

Example 1 with Branch

use of net.nemerosa.ontrack.model.structure.Branch in project ontrack by nemerosa.

the class EntityDataStoreIT method getByCategoryAndName.

@Test
public void getByCategoryAndName() {
    // Entity
    Branch branch = do_create_branch();
    // Adds some data
    // offset: 3
    store.addObject(branch, "C1", "N1", Signature.of(TEST_USER), null, 1);
    // offset: 2
    store.addObject(branch, "C1", "N1", Signature.of(TEST_USER), null, 2);
    // offset: 1
    store.addObject(branch, "C1", "N1", Signature.of(TEST_USER), null, 3);
    // offset: 0
    store.addObject(branch, "C1", "N1", Signature.of(TEST_USER), null, 4);
    store.addObject(branch, "C1", "N2", Signature.of(TEST_USER), null, 5);
    store.addObject(branch, "C2", "N3", Signature.of(TEST_USER), null, 6);
    // Query with pagination
    List<EntityDataStoreRecord> records = store.getByCategoryAndName(branch, "C1", "N1", 2, 1);
    // Checks the results
    assertEquals(1, records.size());
    assertEquals(2, records.get(0).getData().asInt());
    // Count
    assertEquals(4, store.getCountByCategoryAndName(branch, "C1", "N1"));
}
Also used : Branch(net.nemerosa.ontrack.model.structure.Branch) Test(org.junit.Test)

Example 2 with Branch

use of net.nemerosa.ontrack.model.structure.Branch in project ontrack by nemerosa.

the class EntityDataStoreIT method deleteAllByFilter.

@Test
public void deleteAllByFilter() {
    // Entities
    Branch branch1 = do_create_branch();
    Branch branch2 = do_create_branch();
    // Adds some data
    store.deleteAll();
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 1);
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 2);
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 3);
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 4);
    store.addObject(branch1, "C1", "N2", Signature.of(TEST_USER), null, 5);
    store.addObject(branch1, "C2", "N3", Signature.of(TEST_USER), null, 6);
    store.addObject(branch2, "C1", "N1", Signature.of(TEST_USER), null, 7);
    store.addObject(branch2, "C1", "N2", Signature.of(TEST_USER), null, 8);
    store.addObject(branch2, "C2", "N3", Signature.of(TEST_USER), null, 9);
    // Checks
    assertEquals(9, store.deleteByFilter(new EntityDataStoreFilter()));
}
Also used : Branch(net.nemerosa.ontrack.model.structure.Branch) Test(org.junit.Test)

Example 3 with Branch

use of net.nemerosa.ontrack.model.structure.Branch in project ontrack by nemerosa.

the class EntityDataStoreIT method deleteByBranchAndCategoryByFilter.

@Test
public void deleteByBranchAndCategoryByFilter() {
    // Entities
    Branch branch1 = do_create_branch();
    Branch branch2 = do_create_branch();
    // Adds some data
    store.deleteAll();
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 1);
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 2);
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 3);
    store.addObject(branch1, "C1", "N1", Signature.of(TEST_USER), null, 4);
    store.addObject(branch1, "C1", "N2", Signature.of(TEST_USER), null, 5);
    store.addObject(branch1, "C2", "N3", Signature.of(TEST_USER), null, 6);
    store.addObject(branch2, "C1", "N1", Signature.of(TEST_USER), null, 7);
    store.addObject(branch2, "C1", "N2", Signature.of(TEST_USER), null, 8);
    store.addObject(branch2, "C2", "N3", Signature.of(TEST_USER), null, 9);
    // Checks
    assertEquals(5, store.deleteByFilter(new EntityDataStoreFilter().withEntity(branch1).withCategory("C1")));
}
Also used : Branch(net.nemerosa.ontrack.model.structure.Branch) Test(org.junit.Test)

Example 4 with Branch

use of net.nemerosa.ontrack.model.structure.Branch in project ontrack by nemerosa.

the class EntityDataStoreIT method add.

@Test
public void add() throws JsonProcessingException {
    // Entity
    Branch branch = do_create_branch();
    // Adds some data
    String name = uid("T");
    EntityDataStoreRecord record = store.add(branch, CATEGORY, name, Signature.of(TEST_USER), null, new IntNode(15));
    // Checks
    assertNotNull(record);
    assertTrue(record.getId() > 0);
    assertEquals(CATEGORY, record.getCategory());
    assertNotNull(record.getSignature());
    assertEquals(name, record.getName());
    assertNull(record.getGroupName());
    assertEquals(branch.getProjectEntityType(), record.getEntity().getProjectEntityType());
    assertEquals(branch.getId(), record.getEntity().getId());
    assertJsonEquals(new IntNode(15), record.getData());
}
Also used : IntNode(com.fasterxml.jackson.databind.node.IntNode) Branch(net.nemerosa.ontrack.model.structure.Branch) Test(org.junit.Test)

Example 5 with Branch

use of net.nemerosa.ontrack.model.structure.Branch in project ontrack by nemerosa.

the class EntityDataStoreIT method delete_by_name.

@Test
public void delete_by_name() {
    // Entity
    Branch branch = do_create_branch();
    // Adds some data
    String name = uid("T");
    int id = store.add(branch, CATEGORY, name, Signature.of(TEST_USER), null, new IntNode(15)).getId();
    // Gets by ID
    assertTrue(store.getById(branch, id).isPresent());
    // Deletes by name
    store.deleteByName(branch, CATEGORY, name);
    // Gets by ID ot possible any longer
    assertFalse(store.getById(branch, id).isPresent());
}
Also used : IntNode(com.fasterxml.jackson.databind.node.IntNode) Branch(net.nemerosa.ontrack.model.structure.Branch) Test(org.junit.Test)

Aggregations

Branch (net.nemerosa.ontrack.model.structure.Branch)33 Test (org.junit.Test)29 IntNode (com.fasterxml.jackson.databind.node.IntNode)12 Account (net.nemerosa.ontrack.model.security.Account)7 Ack (net.nemerosa.ontrack.model.Ack)6 Project (net.nemerosa.ontrack.model.structure.Project)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 BuildFilterResource (net.nemerosa.ontrack.model.buildfilter.BuildFilterResource)4 NameDescription (net.nemerosa.ontrack.model.structure.NameDescription)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 HttpOutputMessage (org.springframework.http.HttpOutputMessage)3 IOException (java.io.IOException)2 Collectors (java.util.stream.Collectors)2 BranchFilterMgt (net.nemerosa.ontrack.model.security.BranchFilterMgt)2 ProjectView (net.nemerosa.ontrack.model.security.ProjectView)2 ID (net.nemerosa.ontrack.model.structure.ID)2 StructureService (net.nemerosa.ontrack.model.structure.StructureService)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 GraphQLInt (graphql.Scalars.GraphQLInt)1 GraphQLString (graphql.Scalars.GraphQLString)1