use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class InputFormatTest method shouldReturnCorrectDataToMapReduceJob.
@Test
public void shouldReturnCorrectDataToMapReduceJob() throws Exception {
final View view = new View.Builder().build();
final Set<String> expectedResults = new HashSet<>();
for (final Element element : DATA) {
expectedResults.add(element.toString());
}
shouldReturnCorrectDataToMapReduceJob(getSchema(), KeyPackage.BYTE_ENTITY_KEY_PACKAGE, DATA, view, new User(), "instance1", expectedResults);
shouldReturnCorrectDataToMapReduceJob(getSchema(), KeyPackage.CLASSIC_KEY_PACKAGE, DATA, view, new User(), "instance2", expectedResults);
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class InputFormatTest method shouldReturnCorrectDataToMapReduceJobRespectingAuthorizations.
@Test
public void shouldReturnCorrectDataToMapReduceJobRespectingAuthorizations() throws Exception {
final Schema schema = getSchemaWithVisibilities();
final View view = new View.Builder().build();
final Set<String> expectedResultsPublicNotPrivate = new HashSet<>();
final Set<String> expectedResultsPrivate = new HashSet<>();
for (final Element element : DATA_WITH_VISIBILITIES) {
expectedResultsPrivate.add(element.toString());
if (element.getProperty("visibility").equals("public")) {
expectedResultsPublicNotPrivate.add(element.toString());
}
}
final Set<String> privateAuth = new HashSet<>();
privateAuth.add("public");
privateAuth.add("private");
final Set<String> publicNotPrivate = new HashSet<>();
publicNotPrivate.add("public");
final User userWithPrivate = new User("user1", privateAuth);
final User userWithPublicNotPrivate = new User("user1", publicNotPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.BYTE_ENTITY_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPublicNotPrivate, "instance5", expectedResultsPublicNotPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.BYTE_ENTITY_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPrivate, "instance6", expectedResultsPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.CLASSIC_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPublicNotPrivate, "instance7", expectedResultsPublicNotPrivate);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.CLASSIC_KEY_PACKAGE, DATA_WITH_VISIBILITIES, view, userWithPrivate, "instance8", expectedResultsPrivate);
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class InputFormatTest method shouldReturnCorrectDataToMapReduceJobWithView.
@Test
public void shouldReturnCorrectDataToMapReduceJobWithView() throws Exception {
final Schema schema = getSchema();
final View view = new View.Builder().edge(TestGroups.EDGE).build();
final Set<String> expectedResults = new HashSet<>();
for (final Element element : DATA) {
if (element.getGroup().equals(TestGroups.EDGE)) {
expectedResults.add(element.toString());
}
}
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.BYTE_ENTITY_KEY_PACKAGE, DATA, view, new User(), "instance3", expectedResults);
shouldReturnCorrectDataToMapReduceJob(schema, KeyPackage.CLASSIC_KEY_PACKAGE, DATA, view, new User(), "instance4", expectedResults);
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class ByteEntityRangeElementPropertyFilterIteratorTest method shouldOnlyAcceptUndirectedEdges.
@Test
public void shouldOnlyAcceptUndirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.UNDIRECTED_EDGE_ONLY, "true");
put(AccumuloStoreConstants.OUTGOING_EDGE_ONLY, "true");
}
};
filter.validateOptions(options);
// value should not be used
final Value value = null;
// When / Then
for (final Element element : ELEMENTS) {
final boolean expectedResult = element instanceof Edge && !((Edge) element).isDirected();
final Pair<Key> keys = converter.getKeysFromElement(element);
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// self elements are not added the other way round
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getSecond(), value));
}
}
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class ByteEntityRangeElementPropertyFilterIteratorTest method shouldOnlyAcceptDirectedEdges.
@Test
public void shouldOnlyAcceptDirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.DIRECTED_EDGE_ONLY, "true");
}
};
filter.validateOptions(options);
// value should not be used
final Value value = null;
// When / Then
for (final Element element : ELEMENTS) {
final boolean expectedResult = element instanceof Edge && ((Edge) element).isDirected();
final Pair<Key> keys = converter.getKeysFromElement(element);
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// self elements are not added the other way round
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getSecond(), value));
}
}
}
Aggregations