def test_execute_operation(self): gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest') elements = gc.execute_operation( g.GetElements( input=[g.EntitySeed('M5:10')], view=g.View( edges=[g.ElementDefinition(group='JunctionLocatedAt')]))) self.assertEqual([ g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, "SOURCE") ], elements)
def generate_domain_objs(gc): # Generate Domain Objects - single provided element input = gc.execute_operation( g.GenerateObjects(element_generator=g.ElementGenerator( class_name= 'uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator'), input=[ g.Entity('entity', '1'), g.Edge('edge', '1', '2', True) ])) print('Generated input from provided input') print(input) print()
def test_dummy_header(self): """Test that the addition of a dummy header does not effect the standard test""" gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest', headers={"dummy_Header": "value"}) elements = gc.execute_operation( g.GetElements( input=[g.EntitySeed('M5:10')], view=g.View( edges=[g.ElementDefinition(group='JunctionLocatedAt')]))) self.assertEqual([ g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, "SOURCE") ], elements)
def add_elements(gc): # Add Elements gc.execute_operation( g.AddElements( input=[ g.Entity( group='JunctionUse', vertex='M1:1', properties={ 'countByVehicleType': { "uk.gov.gchq.gaffer.types.FreqMap": { 'BUS': 10, 'CAR': 50 } }, 'endDate': { 'java.util.Date': 1034319600000 }, 'count': { 'java.lang.Long': 60 }, 'startDate': { 'java.util.Date': 1034316000000 } } ), g.Edge( group='RoadHasJunction', source='M1', destination='M1:1', directed=True, properties={} ) ] ) ) print('Elements have been added') print()
def add_elements(gc): # Add Elements gc.execute_operation( g.AddElements(input=[ g.Entity(group='JunctionUse', vertex='M1:1', properties={ 'countByVehicleType': g.freq_map({ 'BUS': 10, 'CAR': 50 }), 'endDate': g.date(1034319600000), 'count': g.long(60), 'startDate': g.date(1034316000000) }), g.Edge(group='RoadHasJunction', source='M1', destination='M1:1', directed=True, properties={}) ])) print('Elements have been added') print()