Search in sources :

Example 1 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class AddElementsFromHdfsIT method createGraph.

private Graph createGraph(final Class<? extends AccumuloKeyPackage> keyPackageClass) throws StoreException {
    final Schema schema = Schema.fromJson(StreamUtil.schemas(getClass()));
    final AccumuloProperties properties = AccumuloProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
    properties.setKeyPackageClass(keyPackageClass.getName());
    properties.setInstance("instance_" + keyPackageClass.getName());
    final AccumuloStore store = new MockAccumuloStore();
    store.initialise(schema, properties);
    store.updateConfiguration(createLocalConf(), new View(), new User());
    return new Graph.Builder().store(store).build();
}
Also used : User(uk.gov.gchq.gaffer.user.User) AccumuloProperties(uk.gov.gchq.gaffer.accumulostore.AccumuloProperties) MockAccumuloStore(uk.gov.gchq.gaffer.accumulostore.MockAccumuloStore) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AccumuloStore(uk.gov.gchq.gaffer.accumulostore.AccumuloStore) MockAccumuloStore(uk.gov.gchq.gaffer.accumulostore.MockAccumuloStore) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View)

Example 2 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class AccumuloRangeIDRetrieverTest method shouldRetieveElementsInRangeBetweenSeeds.

private void shouldRetieveElementsInRangeBetweenSeeds(final AccumuloStore store) throws StoreException {
    // Create set to query for
    final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0000"), new EntitySeed("0999")));
    // Retrieve elements when less simple entities are provided than the max number of entries for the batch scanner
    final GetElementsOperation<Pair<ElementSeed>, CloseableIterable<Element>> operation = new GetElementsInRanges<>(defaultView, simpleEntityRanges);
    try {
        final AccumuloRangeIDRetriever retriever = new AccumuloRangeIDRetriever(store, operation, new User());
        assertEquals(numEntries, Iterables.size(retriever));
    } catch (IteratorSettingException e) {
        fail("Unable to construct Range Retriever");
    }
}
Also used : User(uk.gov.gchq.gaffer.user.User) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Example 3 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class JcsJobTrackerTest method shouldOverwriteJob.

@Test
public void shouldOverwriteJob() {
    // Given
    final User user = mock(User.class);
    final OperationChain<?> opChain = mock(OperationChain.class);
    given(opChain.toString()).willReturn("op chain to string");
    final String jobId = "jobId1";
    final JobDetail job1 = new JobDetail(jobId, "userId1", opChain, JobStatus.RUNNING, "description1");
    final JobDetail job2 = new JobDetail(jobId, "userId1", opChain, JobStatus.FINISHED, "description2");
    // When
    jobTracker.addOrUpdateJob(job1, user);
    jobTracker.addOrUpdateJob(job2, user);
    // Then
    final JobDetail resultJob = jobTracker.getJob(jobId, user);
    assertEquals(job2, resultJob);
}
Also used : User(uk.gov.gchq.gaffer.user.User) Test(org.junit.Test)

Example 4 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class JcsJobTrackerTest method shouldValidateJobDetailAndThrowExceptionIfMissingJobId.

@Test
public void shouldValidateJobDetailAndThrowExceptionIfMissingJobId() {
    // Given
    final User user = mock(User.class);
    final OperationChain<?> opChain = mock(OperationChain.class);
    given(opChain.toString()).willReturn("op chain to string");
    final JobDetail job = new JobDetail("", "userId1", opChain, JobStatus.RUNNING, "description");
    // When / Then
    try {
        jobTracker.addOrUpdateJob(job, user);
        fail("Exception expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}
Also used : User(uk.gov.gchq.gaffer.user.User) Test(org.junit.Test)

Example 5 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class JcsJobTrackerTest method shouldValidateJobDetailAndThrowExceptionIfNull.

@Test
public void shouldValidateJobDetailAndThrowExceptionIfNull() {
    // Given
    final User user = mock(User.class);
    final JobDetail job = null;
    // When / Then
    try {
        jobTracker.addOrUpdateJob(job, user);
        fail("Exception expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}
Also used : User(uk.gov.gchq.gaffer.user.User) Test(org.junit.Test)

Aggregations

User (uk.gov.gchq.gaffer.user.User)378 Test (org.junit.jupiter.api.Test)188 Graph (uk.gov.gchq.gaffer.graph.Graph)155 Element (uk.gov.gchq.gaffer.data.element.Element)143 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)128 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)110 HashSet (java.util.HashSet)109 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)104 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)103 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)98 Edge (uk.gov.gchq.gaffer.data.element.Edge)85 Context (uk.gov.gchq.gaffer.store.Context)85 Entity (uk.gov.gchq.gaffer.data.element.Entity)77 Test (org.junit.Test)61 ArrayList (java.util.ArrayList)57 OperationException (uk.gov.gchq.gaffer.operation.OperationException)52 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)49 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)48 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)45 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)43