method2testcases stringlengths 118 3.08k |
|---|
### Question:
Entity_Feature { public String getDevice_feature_model_id() { return device_feature_model_id; } Entity_Feature(tracerengine Trac, Activity activity, String device_feature_model_id, int id, int devId, String device_usage_id, String address, String device_type_id, String description, String name, String state_key, String parameters, String value_type); int getId(); void setId(int id); JSONObject getDevice(); String getDescription(); void setDescription(String description); String getDevice_usage_id(); void setDevice_usage_id(String device_usage_id); String getAddress(); void setAddress(String address); int getDevId(); void setDevId(int devId); String getName(); void setName(String name); String getDevice_feature_model_id(); void setDevice_feature_model_id(String device_feature_model_id); String getState_key(); void setState_key(String state_key); String getParameters(); void setParameters(String parameters); String getValue_type(); void setValue_type(String value_type); int getRessources(); void setState(int state); String getDevice_type(); String getDevice_type_id(); void setDevice_type_id(String device_type_id); String getIcon_name(); }### Answer:
@Test public void testGetDevice_feature_model_id() throws Exception { String device_feature_model_id = client.getDevice_feature_model_id(); Assert.assertEquals(null, device_feature_model_id); client.setDevice_feature_model_id("Device_feature_model_id"); device_feature_model_id = client.getDevice_feature_model_id(); Assert.assertEquals("Device_feature_model_id", device_feature_model_id); } |
### Question:
Entity_client { public int getDevId() { return devId; } Entity_client(int devId, String skey, String Name, int session_type); void setClientType(int type); void setClientId(int id); void setcacheId(int Id); void setDevId(int devId); void setskey(String skey); void setValue(String Value); void setName(String Name); void setTimestamp(String Timestamp); void setType(Boolean type); int getClientType(); int getClientId(); int getcacheId(); int getDevId(); String getskey(); String getValue(); String getName(); String getTimestamp(); Boolean is_Miniwidget(); void client_value_update(String val, String valtimestamp); }### Answer:
@Test public void testGetDevId() throws Exception { int DevId = client.getDevId(); Assert.assertEquals(0, DevId); client.setDevId(125); DevId = client.getDevId(); Assert.assertEquals(125, DevId); } |
### Question:
Entity_client { public String getskey() { return skey; } Entity_client(int devId, String skey, String Name, int session_type); void setClientType(int type); void setClientId(int id); void setcacheId(int Id); void setDevId(int devId); void setskey(String skey); void setValue(String Value); void setName(String Name); void setTimestamp(String Timestamp); void setType(Boolean type); int getClientType(); int getClientId(); int getcacheId(); int getDevId(); String getskey(); String getValue(); String getName(); String getTimestamp(); Boolean is_Miniwidget(); void client_value_update(String val, String valtimestamp); }### Answer:
@Test public void testGetskey() throws Exception { String skey = client.getskey(); Assert.assertEquals(null, skey); client.setskey("Skey"); skey = client.getskey(); Assert.assertEquals("Skey", skey); } |
### Question:
Entity_client { public String getValue() { return currentState; } Entity_client(int devId, String skey, String Name, int session_type); void setClientType(int type); void setClientId(int id); void setcacheId(int Id); void setDevId(int devId); void setskey(String skey); void setValue(String Value); void setName(String Name); void setTimestamp(String Timestamp); void setType(Boolean type); int getClientType(); int getClientId(); int getcacheId(); int getDevId(); String getskey(); String getValue(); String getName(); String getTimestamp(); Boolean is_Miniwidget(); void client_value_update(String val, String valtimestamp); }### Answer:
@Test public void testGetValue() throws Exception { String value = client.getValue(); Assert.assertEquals(null, value); client.setValue("Value"); value = client.getValue(); Assert.assertEquals("Value", value); } |
### Question:
Entity_client { public String getName() { return client_name; } Entity_client(int devId, String skey, String Name, int session_type); void setClientType(int type); void setClientId(int id); void setcacheId(int Id); void setDevId(int devId); void setskey(String skey); void setValue(String Value); void setName(String Name); void setTimestamp(String Timestamp); void setType(Boolean type); int getClientType(); int getClientId(); int getcacheId(); int getDevId(); String getskey(); String getValue(); String getName(); String getTimestamp(); Boolean is_Miniwidget(); void client_value_update(String val, String valtimestamp); }### Answer:
@Test public void testGetName() throws Exception { String name = client.getName(); Assert.assertEquals(null, name); client.setName("Name"); name = client.getName(); Assert.assertEquals("Name", name); } |
### Question:
Entity_client { public String getTimestamp() { return timestamp; } Entity_client(int devId, String skey, String Name, int session_type); void setClientType(int type); void setClientId(int id); void setcacheId(int Id); void setDevId(int devId); void setskey(String skey); void setValue(String Value); void setName(String Name); void setTimestamp(String Timestamp); void setType(Boolean type); int getClientType(); int getClientId(); int getcacheId(); int getDevId(); String getskey(); String getValue(); String getName(); String getTimestamp(); Boolean is_Miniwidget(); void client_value_update(String val, String valtimestamp); }### Answer:
@Test public void testGetTimestamp() throws Exception { String timestamp = client.getTimestamp(); Assert.assertEquals(null, timestamp); client.setTimestamp("Timestamp"); timestamp = client.getTimestamp(); Assert.assertEquals("Timestamp", timestamp); } |
### Question:
Entity_client { public Boolean is_Miniwidget() { return miniwidget; } Entity_client(int devId, String skey, String Name, int session_type); void setClientType(int type); void setClientId(int id); void setcacheId(int Id); void setDevId(int devId); void setskey(String skey); void setValue(String Value); void setName(String Name); void setTimestamp(String Timestamp); void setType(Boolean type); int getClientType(); int getClientId(); int getcacheId(); int getDevId(); String getskey(); String getValue(); String getName(); String getTimestamp(); Boolean is_Miniwidget(); void client_value_update(String val, String valtimestamp); }### Answer:
@Test public void testIs_Miniwidget() throws Exception { Boolean type = client.is_Miniwidget(); Assert.assertEquals(false, type); client.setType(true); type = client.is_Miniwidget(); Assert.assertEquals(true, type); } |
### Question:
Entity_Feature { public String getState_key() { return state_key; } Entity_Feature(tracerengine Trac, Activity activity, String device_feature_model_id, int id, int devId, String device_usage_id, String address, String device_type_id, String description, String name, String state_key, String parameters, String value_type); int getId(); void setId(int id); JSONObject getDevice(); String getDescription(); void setDescription(String description); String getDevice_usage_id(); void setDevice_usage_id(String device_usage_id); String getAddress(); void setAddress(String address); int getDevId(); void setDevId(int devId); String getName(); void setName(String name); String getDevice_feature_model_id(); void setDevice_feature_model_id(String device_feature_model_id); String getState_key(); void setState_key(String state_key); String getParameters(); void setParameters(String parameters); String getValue_type(); void setValue_type(String value_type); int getRessources(); void setState(int state); String getDevice_type(); String getDevice_type_id(); void setDevice_type_id(String device_type_id); String getIcon_name(); }### Answer:
@Test public void testGetState_key() throws Exception { String state_key = client.getState_key(); Assert.assertEquals(null, state_key); client.setState_key("State_key"); state_key = client.getState_key(); Assert.assertEquals("State_key", state_key); } |
### Question:
Entity_Feature { public String getParameters() { return parameters; } Entity_Feature(tracerengine Trac, Activity activity, String device_feature_model_id, int id, int devId, String device_usage_id, String address, String device_type_id, String description, String name, String state_key, String parameters, String value_type); int getId(); void setId(int id); JSONObject getDevice(); String getDescription(); void setDescription(String description); String getDevice_usage_id(); void setDevice_usage_id(String device_usage_id); String getAddress(); void setAddress(String address); int getDevId(); void setDevId(int devId); String getName(); void setName(String name); String getDevice_feature_model_id(); void setDevice_feature_model_id(String device_feature_model_id); String getState_key(); void setState_key(String state_key); String getParameters(); void setParameters(String parameters); String getValue_type(); void setValue_type(String value_type); int getRessources(); void setState(int state); String getDevice_type(); String getDevice_type_id(); void setDevice_type_id(String device_type_id); String getIcon_name(); }### Answer:
@Test public void testGetParameters() throws Exception { String parameters = client.getParameters(); Assert.assertEquals(null, parameters); client.setParameters("Parameters"); parameters = client.getParameters(); Assert.assertEquals("Parameters", parameters); } |
### Question:
Entity_Feature { public String getValue_type() { return value_type; } Entity_Feature(tracerengine Trac, Activity activity, String device_feature_model_id, int id, int devId, String device_usage_id, String address, String device_type_id, String description, String name, String state_key, String parameters, String value_type); int getId(); void setId(int id); JSONObject getDevice(); String getDescription(); void setDescription(String description); String getDevice_usage_id(); void setDevice_usage_id(String device_usage_id); String getAddress(); void setAddress(String address); int getDevId(); void setDevId(int devId); String getName(); void setName(String name); String getDevice_feature_model_id(); void setDevice_feature_model_id(String device_feature_model_id); String getState_key(); void setState_key(String state_key); String getParameters(); void setParameters(String parameters); String getValue_type(); void setValue_type(String value_type); int getRessources(); void setState(int state); String getDevice_type(); String getDevice_type_id(); void setDevice_type_id(String device_type_id); String getIcon_name(); }### Answer:
@Test public void testGetValue_type() throws Exception { String value_type = client.getValue_type(); Assert.assertEquals(null, value_type); client.setValue_type("Value_Type"); value_type = client.getValue_type(); Assert.assertEquals("Value_Type", value_type); } |
### Question:
Entity_Feature { public String getDevice_type() { if (device_type_id != null) { String[] model = device_type_id.split("\\."); try { return model[1]; } catch (Exception e) { return model[0]; } } else return null; } Entity_Feature(tracerengine Trac, Activity activity, String device_feature_model_id, int id, int devId, String device_usage_id, String address, String device_type_id, String description, String name, String state_key, String parameters, String value_type); int getId(); void setId(int id); JSONObject getDevice(); String getDescription(); void setDescription(String description); String getDevice_usage_id(); void setDevice_usage_id(String device_usage_id); String getAddress(); void setAddress(String address); int getDevId(); void setDevId(int devId); String getName(); void setName(String name); String getDevice_feature_model_id(); void setDevice_feature_model_id(String device_feature_model_id); String getState_key(); void setState_key(String state_key); String getParameters(); void setParameters(String parameters); String getValue_type(); void setValue_type(String value_type); int getRessources(); void setState(int state); String getDevice_type(); String getDevice_type_id(); void setDevice_type_id(String device_type_id); String getIcon_name(); }### Answer:
@Test public void testGetDevice_type() throws Exception { String device_type = client.getDevice_type(); Assert.assertEquals(null, device_type); client.setDevice_type_id("device_type"); device_type = client.getDevice_type(); Assert.assertEquals("device_type", device_type); client.setDevice_type_id("device_type.devicepart2"); device_type = client.getDevice_type(); Assert.assertEquals("devicepart2", device_type); } |
### Question:
Entity_Feature { public String getDevice_type_id() { return device_type_id; } Entity_Feature(tracerengine Trac, Activity activity, String device_feature_model_id, int id, int devId, String device_usage_id, String address, String device_type_id, String description, String name, String state_key, String parameters, String value_type); int getId(); void setId(int id); JSONObject getDevice(); String getDescription(); void setDescription(String description); String getDevice_usage_id(); void setDevice_usage_id(String device_usage_id); String getAddress(); void setAddress(String address); int getDevId(); void setDevId(int devId); String getName(); void setName(String name); String getDevice_feature_model_id(); void setDevice_feature_model_id(String device_feature_model_id); String getState_key(); void setState_key(String state_key); String getParameters(); void setParameters(String parameters); String getValue_type(); void setValue_type(String value_type); int getRessources(); void setState(int state); String getDevice_type(); String getDevice_type_id(); void setDevice_type_id(String device_type_id); String getIcon_name(); }### Answer:
@Test public void testGetDevice_type_id() throws Exception { String device_type_id = client.getDevice_type_id(); Assert.assertEquals(null, device_type_id); client.setDevice_type_id("Device_Type_ID"); device_type_id = client.getDevice_type_id(); Assert.assertEquals("Device_Type_ID", device_type_id); } |
### Question:
Entity_Feature { public String getIcon_name() { String iconName = "unknow"; DomodroidDB domodb = DomodroidDB.getInstance(Tracer, activity); domodb.owner = "entity_feature"; try { iconName = domodb.requestIcons(id, "feature").getValue(); } catch (Exception e) { } if (iconName.equals("unknow")) iconName = device_usage_id; return iconName.toLowerCase(); } Entity_Feature(tracerengine Trac, Activity activity, String device_feature_model_id, int id, int devId, String device_usage_id, String address, String device_type_id, String description, String name, String state_key, String parameters, String value_type); int getId(); void setId(int id); JSONObject getDevice(); String getDescription(); void setDescription(String description); String getDevice_usage_id(); void setDevice_usage_id(String device_usage_id); String getAddress(); void setAddress(String address); int getDevId(); void setDevId(int devId); String getName(); void setName(String name); String getDevice_feature_model_id(); void setDevice_feature_model_id(String device_feature_model_id); String getState_key(); void setState_key(String state_key); String getParameters(); void setParameters(String parameters); String getValue_type(); void setValue_type(String value_type); int getRessources(); void setState(int state); String getDevice_type(); String getDevice_type_id(); void setDevice_type_id(String device_type_id); String getIcon_name(); }### Answer:
@Test public void testGetIcon_name() throws Exception { } |
### Question:
Entity_Area { public String getIcon_name() { String iconName = "unknow"; DomodroidDB domodb = DomodroidDB.getInstance(Tracer, activity); domodb.owner = "entity_area"; try { iconName = domodb.requestIcons(id, "area").getValue(); } catch (Exception e) { } return iconName; } Entity_Area(tracerengine Trac, Activity activity, String description, int id, String name); String getDescription(); void setDescription(String description); int getId(); void setId(int id); String getName(); void setName(String name); String getIcon_name(); }### Answer:
@Test public void testGetIcon_name() throws Exception { } |
### Question:
Entity_Feature_Association { public int getPlace_id() { return place_id; } Entity_Feature_Association(int place_id, String place_type, int device_feature_id, int id, String device_feature); int getPlace_id(); void setPlace_id(int placeId); String getPlace_type(); void setPlace_type(String placeType); int getDevice_feature_id(); void setDevice_feature_id(int deviceFeatureId); int getId(); void setId(int id); JSONObject getDevice_feature(); void setDevice_feature(JSONObject json_deviceFeature); String getFeat_model_id(); int getFeat_id(); int getFeat_device_id(); }### Answer:
@Test public void testGetPlace_id() throws Exception { Entity_Feature_Association feature_association = new Entity_Feature_Association(0, null, 0, 0, null); int placeid = feature_association.getPlace_id(); Assert.assertEquals(0, placeid); feature_association.setPlace_id(125); placeid = feature_association.getPlace_id(); Assert.assertEquals(125, placeid); } |
### Question:
UserController { @GetMapping(path = "/users/{userId}/commands/recommendFriends") public Flux<RankedUser> recommendFriends(@PathVariable Long userId) { return Flux.fromIterable(friendRepository.recommendedFriends(userId)); } UserController(FriendRepository friendRepository); @GetMapping(path = "/users/{userId}/commands/findMutualFriends") Flux<User> getMutualFriends(@PathVariable Long userId, @RequestParam Long friendId); @GetMapping(path = "/users/{userId}/commands/recommendFriends") Flux<RankedUser> recommendFriends(@PathVariable Long userId); }### Answer:
@Test public void testRecommendFriends() throws Exception { ObjectMapper mapper = new ObjectMapper(); this.webClient.get().uri("/v1/users/1/commands/recommendFriends") .accept(MediaType.APPLICATION_JSON) .exchange().expectBody() .json(mapper.writeValueAsString(friendRepository.recommendedFriends(1L).toList().toArray())); } |
### Question:
LocalOntology implements Ontology { @Override public void load() { URL ontURL = null; try { ontURL = new URL("http: } catch (MalformedURLException e) { LOG.error("Error when attempting to create URL resource: ", e); } ontArrayList = new ArrayList<>(); try { if(ontURL != null){ ontArrayList.add(ontURL.toURI().toString()); } } catch (URISyntaxException e) { LOG.error("Error in URL syntax, please check your Ontology resource: ", e); } if (!ontArrayList.isEmpty()) { load(ontArrayList.toArray(new String[0])); } } LocalOntology(); Ontology getInstance(); @Override void load(); @Override void load(String[] urls); OntologyParser getParser(); static OntModel getModel(); List<String> getLoadedOntologyResources(); @Override void merge(Ontology o); @Override Iterator<String> subclasses(String entitySearchTerm); @Override Iterator synonyms(String queryKeyPhrase); void addSearchTerm(String label, OntResource resource); Map<OntResource, String> retrieve(String label); static void renderClassDescription(PrintStream out, OntClass c, int depth); static final Logger LOG; static final String DELIMITER_SEARCHTERM; }### Answer:
@Ignore @Test public final void testLoad() throws IOException { lOnt.load(); assertTrue("Resource list should have a minimum of one resource.", lOnt.getLoadedOntologyResources().size() == 1); } |
### Question:
LocalOntology implements Ontology { public void addSearchTerm(String label, OntResource resource) { Map<OntResource, String> m = retrieve(label); if (m == null) { m = new HashMap<>(); } m.put(resource, "1"); searchTerms.put(label.toLowerCase(Locale.ENGLISH), m); } LocalOntology(); Ontology getInstance(); @Override void load(); @Override void load(String[] urls); OntologyParser getParser(); static OntModel getModel(); List<String> getLoadedOntologyResources(); @Override void merge(Ontology o); @Override Iterator<String> subclasses(String entitySearchTerm); @Override Iterator synonyms(String queryKeyPhrase); void addSearchTerm(String label, OntResource resource); Map<OntResource, String> retrieve(String label); static void renderClassDescription(PrintStream out, OntClass c, int depth); static final Logger LOG; static final String DELIMITER_SEARCHTERM; }### Answer:
@Ignore @Test public final void testAddSearchTerm() { fail("Not yet implemented"); } |
### Question:
LocalOntology implements Ontology { public Map<OntResource, String> retrieve(String label) { @SuppressWarnings("unchecked") Map<OntResource, String> m = (Map<OntResource, String>) searchTerms.get(label.toLowerCase(Locale.ENGLISH)); if (m == null) { m = new HashMap<>(); } return m; } LocalOntology(); Ontology getInstance(); @Override void load(); @Override void load(String[] urls); OntologyParser getParser(); static OntModel getModel(); List<String> getLoadedOntologyResources(); @Override void merge(Ontology o); @Override Iterator<String> subclasses(String entitySearchTerm); @Override Iterator synonyms(String queryKeyPhrase); void addSearchTerm(String label, OntResource resource); Map<OntResource, String> retrieve(String label); static void renderClassDescription(PrintStream out, OntClass c, int depth); static final Logger LOG; static final String DELIMITER_SEARCHTERM; }### Answer:
@Ignore @Test public final void testRetrieve() { fail("Not yet implemented"); } |
### Question:
LocalOntology implements Ontology { public static void renderClassDescription(PrintStream out, OntClass c, int depth) { indent(out, depth); if (c.isRestriction()) { renderRestriction(out, c.as(Restriction.class)); } else { if (!c.isAnon()) { out.print("Class "); renderURI(out, c.getModel(), c.getURI()); out.print(c.getLocalName()); out.print(" ["); for (Iterator<?> i = c.listLabels(null); i.hasNext(); ) { out.print(((Literal) i.next()).getString() + ", "); } out.print("] "); } else { renderAnonymous(out, c, "class"); } } } LocalOntology(); Ontology getInstance(); @Override void load(); @Override void load(String[] urls); OntologyParser getParser(); static OntModel getModel(); List<String> getLoadedOntologyResources(); @Override void merge(Ontology o); @Override Iterator<String> subclasses(String entitySearchTerm); @Override Iterator synonyms(String queryKeyPhrase); void addSearchTerm(String label, OntResource resource); Map<OntResource, String> retrieve(String label); static void renderClassDescription(PrintStream out, OntClass c, int depth); static final Logger LOG; static final String DELIMITER_SEARCHTERM; }### Answer:
@Ignore @Test public final void testRenderClassDescription() { fail("Not yet implemented"); } |
### Question:
MudrodEngine { public Properties loadConfig() { InputStream configStream = locateConfig(); try { props.load(configStream); for(String key : props.stringPropertyNames()) { props.put(key, props.getProperty(key).trim()); } String rankingModelPath = props.getProperty(MudrodConstants.RANKING_MODEL); props.put(MudrodConstants.RANKING_MODEL, decompressSVMWithSGDModel(rankingModelPath)); } catch (IOException e) { LOG.info("Fail to load the sytem config file"); } return getConfig(); } MudrodEngine(); ESDriver startESDriver(); SparkDriver startSparkDriver(); Properties getConfig(); ESDriver getESDriver(); void setESDriver(ESDriver es); Properties loadConfig(); void startLogIngest(); void startMetaIngest(); void startFullIngest(); void startProcessing(); void end(); static void main(String[] args); SparkDriver getSparkDriver(); void setSparkDriver(SparkDriver sparkDriver); }### Answer:
@Ignore @Test public final void testLoadConfig() { fail("Not yet implemented"); } |
### Question:
MudrodEngine { public void startLogIngest() { DiscoveryEngineAbstract wd = new WeblogDiscoveryEngine(props, es, spark); wd.preprocess(); wd.process(); LOG.info("Logs have been ingested successfully"); } MudrodEngine(); ESDriver startESDriver(); SparkDriver startSparkDriver(); Properties getConfig(); ESDriver getESDriver(); void setESDriver(ESDriver es); Properties loadConfig(); void startLogIngest(); void startMetaIngest(); void startFullIngest(); void startProcessing(); void end(); static void main(String[] args); SparkDriver getSparkDriver(); void setSparkDriver(SparkDriver sparkDriver); }### Answer:
@Ignore @Test public final void testStartLogIngest() { fail("Not yet implemented"); } |
### Question:
GraphRelationshipMutation implements Mutation { @Override public Mutation setAttribute(Name name, Object value) { operatons.setAttributeValue(name, value); return this; } GraphRelationshipMutation(Relationship relationship,
OperationPipeline pipeline,
BatchMutation batchMutation); @Override Mutation setAttribute(Name name, Object value); @Override Mutation deleteAttribute(Name name); @Override com.intuit.ugc.api.BatchMutation ready(); @Override Mutation delete(); }### Answer:
@Test public void testSetAttribute(){ GraphRelationship graphRelationship = createGraphRelationship(); OperationPipeline pipeline = new OperationPipeline(); BatchMutation batchMutation = new MockBatchMutation(); GraphRelationshipMutation graphRelationshipMutation = new GraphRelationshipMutation(graphRelationship, pipeline, batchMutation ); Object value = "dummyValue"; Mutation setAttribute = graphRelationshipMutation.setAttribute(TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME, value); assertNotNull(setAttribute); } |
### Question:
GraphProjection implements Queries.Projection { @Override public Queries.Projection includeAttribute(Attribute.Name name) { getTerminal().include(name); return this; } @Inject GraphProjection(GraphVisitor repository,
OperationPipeline aPipeline); @Override Queries.Projection includeAttribute(Attribute.Name name); @Override Queries.Projection includeAttributes(Attribute.Family namespace); @Override Query ready(); }### Answer:
@Test public void testIncludeAttribute(){ GraphVisitor repository = new MockGraphVisitor(); GraphProjection graphProjection = new GraphProjection(repository, new OperationPipeline()); Projection includeAttribute = graphProjection.includeAttribute(TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME); assertNotNull(includeAttribute); }
@Test public void testTerminalOperationProjection(){ OperationPipeline operationPipeline = new OperationPipeline(); GraphTerminalOperation terminalOperation = new GraphTerminalOperation(); operationPipeline.add(terminalOperation); GraphVisitor repository = new MockGraphVisitor(); GraphProjection graphProjection = new GraphProjection(repository, new OperationPipeline()); Projection includeAttribute = graphProjection.includeAttribute(TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME); assertNotNull(includeAttribute); } |
### Question:
GraphProjection implements Queries.Projection { @Override public Queries.Projection includeAttributes(Attribute.Family namespace) { getTerminal().include(namespace); return this; } @Inject GraphProjection(GraphVisitor repository,
OperationPipeline aPipeline); @Override Queries.Projection includeAttribute(Attribute.Name name); @Override Queries.Projection includeAttributes(Attribute.Family namespace); @Override Query ready(); }### Answer:
@Test public void testIncludeAttributesFamily(){ GraphVisitor repository = new MockGraphVisitor(); GraphProjection graphProjection = new GraphProjection(repository, new OperationPipeline()); Projection includeAttributes = graphProjection.includeAttributes(TartanImplTestConstants.ATTR_DUMMY_FAMILY); assertNotNull(includeAttributes); } |
### Question:
GraphProjection implements Queries.Projection { @Override public Query ready() { return new QueryImpl(repository, pipeline); } @Inject GraphProjection(GraphVisitor repository,
OperationPipeline aPipeline); @Override Queries.Projection includeAttribute(Attribute.Name name); @Override Queries.Projection includeAttributes(Attribute.Family namespace); @Override Query ready(); }### Answer:
@Test public void testReadyAndExecute(){ GraphVisitor repository = new MockGraphVisitor(); GraphProjection graphProjection = new GraphProjection(repository, new OperationPipeline()); Query ready = graphProjection.ready(); OperationResult<Result> execute = ready.execute(); assertNotNull(execute); } |
### Question:
GraphLookUpQuery implements Queries.LookupQuery { @Override public Queries.Projection entities(Entity.ID... entityIDs) { Preconditions.argumentNotNull(entityIDs, "entityIDs"); OperationPipeline pipeline = new OperationPipeline(); pipeline.add(new GetBatchEntityByID(Arrays.asList(entityIDs))); return new GraphProjection(repository, pipeline); } GraphLookUpQuery(final GraphVisitor repository); @Override Queries.Projection entities(Entity.ID... entityIDs); @Override Queries.Projection entity(Entity.ID entityID); @Override ValueSpecifier<Projection> entityBy(Name name); }### Answer:
@Test public void testEntitiesWithNull(){ GraphVisitor repository = new MockGraphVisitor(); GraphLookUpQuery graphLookupQuery = new GraphLookUpQuery(repository); try{ @SuppressWarnings("unused") Projection entities = graphLookupQuery.entities(null); fail("Should have thrown with null entities"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"entityIDs\" cannot be null"); } }
@Test public void testEntitiesWithValidArgument(){ Entity.ID newEntityID = Entity.ID.valueOf("urn:entity:" + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "." + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "/" + UUID.randomUUID()); GraphVisitor repository = new MockGraphVisitor(); GraphLookUpQuery graphLookupQuery = new GraphLookUpQuery(repository); Projection entities = graphLookupQuery.entities(newEntityID); assertNotNull(entities); } |
### Question:
GraphLookUpQuery implements Queries.LookupQuery { @Override public Queries.Projection entity(Entity.ID entityID) { Preconditions.argumentNotNull(entityID, "entityID"); OperationPipeline pipeline = new OperationPipeline(); pipeline.add(new GetEntityByID(entityID)); return new GraphProjection(repository, pipeline); } GraphLookUpQuery(final GraphVisitor repository); @Override Queries.Projection entities(Entity.ID... entityIDs); @Override Queries.Projection entity(Entity.ID entityID); @Override ValueSpecifier<Projection> entityBy(Name name); }### Answer:
@Test public void testEntityWithNullInput(){ GraphVisitor repository = new MockGraphVisitor(); GraphLookUpQuery graphLookupQuery = new GraphLookUpQuery(repository); try{ graphLookupQuery.entity(null); fail("Should have thrown with null entities"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"entityID\" cannot be null"); } }
@Test public void testEntityWithValidArgument(){ Entity.ID newEntityID = Entity.ID.valueOf("urn:entity:" + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "." + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "/" + UUID.randomUUID()); GraphVisitor repository = new MockGraphVisitor(); GraphLookUpQuery graphLookupQuery = new GraphLookUpQuery(repository); Projection entity = graphLookupQuery.entity(newEntityID); assertNotNull(entity); } |
### Question:
GraphLookUpQuery implements Queries.LookupQuery { @Override public ValueSpecifier<Projection> entityBy(Name name) { return new GraphValueChange(name); } GraphLookUpQuery(final GraphVisitor repository); @Override Queries.Projection entities(Entity.ID... entityIDs); @Override Queries.Projection entity(Entity.ID entityID); @Override ValueSpecifier<Projection> entityBy(Name name); }### Answer:
@Test public void testFetchGraphValueChange(){ GraphVisitor repository = new MockGraphVisitor(); GraphLookUpQuery graphLookupQuery = new GraphLookUpQuery(repository); ValueSpecifier<Projection> projection = graphLookupQuery.entityBy(TartanImplTestConstants.ATTR_PARENT_ID); assertNotNull(projection); } |
### Question:
GraphMutationResult implements BatchMutation.Result, VisitOperationResult { public List<String> getEntityKeys() { return entityKeys; } GraphMutationResult(); GraphMutationResult(List<String> entityKeys); List<String> getEntityKeys(); }### Answer:
@Test public void testCreateGraphMutationResultWithEntityKeys(){ List<String> entityKeys = new ArrayList<String>(Arrays.asList("Key1", "Key2", "Key3")); GraphMutationResult graphMutationResult = new GraphMutationResult(entityKeys ); List<String> entityKeysReturned = graphMutationResult.getEntityKeys(); assertNotNull(entityKeysReturned); assertEquals(entityKeys.size(), entityKeysReturned.size()); assertEquals(entityKeys, entityKeysReturned); }
@Test public void testCreateGraphMutationResultWithoutKeys(){ GraphMutationResult graphMutationResult = new GraphMutationResult(); assertEquals(Collections.emptyList(), graphMutationResult.getEntityKeys()); } |
### Question:
StreamComparison implements Comparison { @Override public StreamPredicateBuilder greaterThan(Object o) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } StreamComparison(StreamPredicateBuilder pb); StreamComparison get(Attribute.Name name); @Override StreamPredicateBuilder equalTo(Object value); @Override StreamPredicateBuilder notEqualTo(Object o); @Override StreamPredicateBuilder greaterThan(Object o); @Override StreamPredicateBuilder lessThan(Object o); }### Answer:
@Test public void testStreamComparisonGreaterThan(){ try{ StreamPredicateBuilder pb = new StreamPredicateBuilder(); StreamComparison streamComparison = new StreamComparison(pb ); Object o = null; streamComparison.greaterThan(o); }catch(Exception e){ assertTrue(e instanceof UnsupportedOperationException); } } |
### Question:
GraphAttributeOperations { public void setAttributeValue(Name name, Object value) { if (value == null) { unsetAttributeValue(name); } else { Preconditions.argumentNotNull(name,"name::Atribute.Name"); setOperations.put(name, value); } } GraphAttributeOperations(); void setAttributeValue(Name name, Object value); void unsetAttributeValue(Name name); Map<Name, Object> getSetValueOperations(); List<Name> getUnsetValueOperations(); }### Answer:
@Test public void testGraphAttributeOperationsCreationWithNullName(){ GraphAttributeOperations graphAttributeOperations = new GraphAttributeOperations(); Name name = null; String attributeOperationValue = "DummySetOperationValue1"; try{ graphAttributeOperations.setAttributeValue(name, attributeOperationValue); fail("Should throw an exception with null attribute name"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"name::Atribute.Name\" cannot be null"); } } |
### Question:
DSEPersistenceRepositoryProvider implements Provider<DSEGraphVisitor> { @Override public DSEGraphVisitor get() { return new DSEGraphVisitor(this.manager); } @Inject DSEPersistenceRepositoryProvider(DSEConnectionManager manager); @Override DSEGraphVisitor get(); }### Answer:
@Test public void testInit() { try { DSEPersistenceRepositoryProvider provider = new DSEPersistenceRepositoryProvider( new DSEConnectionManagerMock(new DSEConfigurationMock())); DSEGraphVisitor dseGraphVisitor = provider.get(); assertNotNull(dseGraphVisitor); } catch (Exception e) { fail("shouldn't have thrown"); } } |
### Question:
DSEMetadata implements Metadata { public Class<T> getType() { return this.type; } DSEMetadata(Class<T> type); Class<T> getType(); }### Answer:
@Test public void testCreateDSEMetadata(){ DSEMetadata<String> metadata = new DSEMetadata<>(String.class); assertEquals(metadata.getType(), String.class); } |
### Question:
GraphEntityOperations extends GraphOperations { public GraphMutationResult createEntity(NewEntity newEntity) { String entityId = newEntity.getEntityID().toString(); Map<Attribute.Name, Object> attributes = newEntity.getAttributes(); String entityProperty = attributes.entrySet().stream() .map(e -> String.format(GraphOperations.ENTITY_PROPERTY_FORMAT, e.getKey(), e.getValue())) .collect(Collectors.joining()); StringBuilder sb = new StringBuilder(); Attribute.Name labelKey = Attribute.Name.valueOf("dse.vertex.Label"); if (attributes.containsKey(labelKey)) { sb.append(String.format(GraphOperations.ADD_ENTITY_WITH_LABEL, (String) attributes.get(labelKey))); } else { sb.append(GraphOperations.ADD_ENTITY); } sb.append(String.format(GraphOperations.ENTITY_PROPERTY_FORMAT, ENTITY_ID.toString(), entityId)); sb.append(entityProperty); GraphResultSet result = executeGraphQuery(sb); return extractGraphQueryResult(result); } GraphEntityOperations(DSEConnectionManager connectionManager,
GraphRelationshipOperations relationshipOperations); GraphMutationResult createEntity(NewEntity newEntity); VisitOperationResult getEntitiesByID(List<ID> entityIDs); GraphResultSet getEntityById(Entity.ID entityId); VisitOperationResult selectEntities(com.intuit.ugc.api.Relationship.Name relationName,
Direction direction, Predicate predicate, QueryResult<Entity, Relationship> context); GraphResultSet getEntityByProperty(GetEntityByProperty operation); void deleteEntity(Entity entity); VisitOperationResult updateEntity(Entity entity, GraphAttributeOperations operations); QueryResultImpl createQueryResult(GraphResultSet result); List<Entity> filterEntity(List<Entity> entityResponse,
List<Name> nameList, List<Family> namespaceList); }### Answer:
@Test public void testCreateEntity(){ } |
### Question:
DSEConnectionManager { public SimpleGraphStatement getStatement(String cmd) { SimpleGraphStatement sVertexStatement = new SimpleGraphStatement(cmd); sVertexStatement.setGraphName(config.getGraph()); return sVertexStatement; } @Inject DSEConnectionManager(DSEPersistenceConfiguration config); SimpleGraphStatement getStatement(String cmd); DSEGraphSession getDSEGraphSession(); }### Answer:
@Test public void testGetStatement(){ DSEConfigurationMock config = new DSEConfigurationMock(); DSEConnectionManager dseConnectionManager = new DSEConnectionManager(config); SimpleGraphStatement statement = dseConnectionManager.getStatement("mock-command"); AssertJUnit.assertNotNull(statement); AssertJUnit.assertEquals(statement.getGraphName(), config.getGraph()); assertNotNull(dseConnectionManager.getDSEGraphSession()); } |
### Question:
NewEntity { public static Builder newInstance(Entity.ID entityID) { return new Builder(entityID); } private NewEntity(Entity.ID entityID); static Builder newInstance(Entity.ID entityID); Map<Attribute.Name, Object> getAttributes(); Entity.ID getEntityID(); }### Answer:
@Test public void testInitWithNullAttributeThrowsException(){ ID entityID = Entity.ID.valueOf("test-entity-id"); try{ NewEntity newEntity = NewEntity.newInstance(entityID) .withAttribute(null).value(true).build(); fail("Should throw an exception"); }catch(Exception ex){ assertTrue(ex instanceof IllegalArgumentException); } } |
### Question:
StreamComparison implements Comparison { @Override public StreamPredicateBuilder lessThan(Object o) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } StreamComparison(StreamPredicateBuilder pb); StreamComparison get(Attribute.Name name); @Override StreamPredicateBuilder equalTo(Object value); @Override StreamPredicateBuilder notEqualTo(Object o); @Override StreamPredicateBuilder greaterThan(Object o); @Override StreamPredicateBuilder lessThan(Object o); }### Answer:
@Test public void testStreamComparisonLessThan(){ try{ StreamPredicateBuilder pb = new StreamPredicateBuilder(); StreamComparison streamComparison = new StreamComparison(pb ); Object o = null; streamComparison.lessThan(o); }catch(Exception e){ assertTrue(e instanceof UnsupportedOperationException); } } |
### Question:
AbstractValueSpecifier implements ValueSpecifier<B> { protected abstract void setValue(Object value); protected AbstractValueSpecifier(B builder, Attribute.Name name); @Override final B value(String value); @Override final B value(Integer value); @Override final B value(Double value); @Override final B value(Boolean value); @Override final B value(Instant value); @Override B value(Object value, TypeConverter.Conversion<T> converter); }### Answer:
@Test public void testAbstractValueSpecifierWithObject(){ ValueBuilder valueBuilder = new ValueBuilder(); String name = "attr-name"; Object value = "attr-value"; valueBuilder.withAttribute(Attribute.Name.valueOf(name)).setValue(value); } |
### Question:
AbstractQualifiedName { @Override public boolean equals(Object object) { if (this == object) { return true; } if (object == null) { return false; } if (getClass() != object.getClass()) { return false; } final AbstractQualifiedName other = (AbstractQualifiedName)object; if (!Objects.equals(this.getName(), other.getName())) { return false; } return true; } protected AbstractQualifiedName(String name); final String getName(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object object); }### Answer:
@Test public void testAbstractQualifiedNameEquality(){ String name1 = "test-name-1"; AbstractQualifiedName aqn1 = new QualifiedName(name1); AbstractQualifiedName aqn2 = new QualifiedName(name1); String name2 = "test-name-2"; AbstractQualifiedName aqn3 = new QualifiedName(name2); assertTrue(aqn1.equals(aqn1)); assertTrue(aqn1.equals(aqn2)); assertFalse(aqn1.equals(aqn3)); assertFalse(aqn1.equals(null)); assertFalse(aqn1.equals(name1)); } |
### Question:
StreamComparison implements Comparison { @Override public StreamPredicateBuilder notEqualTo(Object o) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } StreamComparison(StreamPredicateBuilder pb); StreamComparison get(Attribute.Name name); @Override StreamPredicateBuilder equalTo(Object value); @Override StreamPredicateBuilder notEqualTo(Object o); @Override StreamPredicateBuilder greaterThan(Object o); @Override StreamPredicateBuilder lessThan(Object o); }### Answer:
@Test public void testStreamComparisonNotEqualToThan(){ try{ StreamPredicateBuilder pb = new StreamPredicateBuilder(); StreamComparison streamComparison = new StreamComparison(pb ); Object o = null; streamComparison.notEqualTo(o); }catch(Exception e){ assertTrue(e instanceof UnsupportedOperationException); } } |
### Question:
OrPredicate implements StreamPredicate, CompoundPredicate { @Override public StreamPredicate[] getPredicates() { return predicates; } OrPredicate(); OrPredicate(StreamPredicate... predicates); @Override StreamPredicate[] getPredicates(); @Override void setPredicates(StreamPredicate[] predicates); @Override boolean apply(Collection<Attribute> attributes); }### Answer:
@Test public void testOrPredicateWithEmptyParams(){ StreamPredicate[] predicates = new StreamPredicate[0]; OrPredicate orPredicate = new OrPredicate(predicates); assertNotNull(orPredicate.getPredicates()); } |
### Question:
OrPredicate implements StreamPredicate, CompoundPredicate { @Override public boolean apply(Collection<Attribute> attributes) { for (StreamPredicate predicate : predicates) { if (predicate.apply(attributes)) { return true; } } return false; } OrPredicate(); OrPredicate(StreamPredicate... predicates); @Override StreamPredicate[] getPredicates(); @Override void setPredicates(StreamPredicate[] predicates); @Override boolean apply(Collection<Attribute> attributes); }### Answer:
@Test public void testApplyWithValidAttributes(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); Object attributeValue = "test-attr-value"; EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName, attributeValue); GraphAttribute graphAttribute = new GraphAttribute(attributeName, attributeValue, new MockMetadata()); List<Attribute> attributes = new ArrayList<Attribute>( Arrays.asList(graphAttribute)); StreamPredicate[] predicates = new StreamPredicate[1]; predicates[0] = equalToPredicate; OrPredicate orPredicate = new OrPredicate(predicates); assertTrue(orPredicate.apply(attributes)); }
@Test public void testApplyWithInvalidAttributes(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); Object attributeValue = "test-attr-value"; EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName, attributeValue+"1"); GraphAttribute graphAttribute = new GraphAttribute(attributeName, attributeValue, new MockMetadata()); List<Attribute> attributes = new ArrayList<Attribute>( Arrays.asList(graphAttribute)); StreamPredicate[] predicates = new StreamPredicate[1]; predicates[0] = equalToPredicate; OrPredicate orPredicate = new OrPredicate(predicates); assertFalse(orPredicate.apply(attributes)); }
@Test public void testApplyWithEmptyPredicateList(){ StreamPredicate[] predicates = new StreamPredicate[0]; OrPredicate orPredicate = new OrPredicate(predicates); assertFalse(orPredicate.apply(Collections.emptyList())); } |
### Question:
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder and(StreamPredicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"and\" statement expected: " + StreamPredicateBuilder.class.getSimpleName() + ", found: " + ((Objects.isNull(predicate)) ? "null" : predicate.getClass().getSimpleName())); } int index = predicateList.size() - 2; StreamPredicate first = predicateList.remove(index); StreamPredicate second = predicateList.remove(index); predicateList.add(StreamPredicates.and(first, second)); return this; } StreamPredicateBuilder(); Attribute.Name getAttribute(); void setAttribute(Attribute.Name attributeName); @Override boolean apply(Collection<Attribute> attributes); StreamComparison getComparison(); StreamPredicateBuilder and(StreamPredicate predicate); StreamPredicateBuilder or(Predicate predicate); @Override Comparison attribute(Attribute.Name name); @Override Predicate and(Predicate... predicates); @Override Predicate or(Predicate... predicates); }### Answer:
@Test public void testStreamPredicateBuilderAndWithMultiPredicate() { StreamPredicateBuilder spb = new StreamPredicateBuilder(); try{ spb.and(null, null); fail("should throw unsupported operation exception"); }catch(Exception e){ assertTrue(e instanceof UnsupportedOperationException); } }
@Test public void testAndWithNullPredicateInstance(){ StreamPredicateBuilder spb = new StreamPredicateBuilder(); StreamPredicateBuilder spb2 = null; try{ spb.and(spb2); fail("should throw"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } }
@Test public void testAndWithDiffPredicateInstance(){ StreamPredicateBuilder spb = new StreamPredicateBuilder(); StreamPredicateBuilder spb2 = new StreamPredicateBuilder(); try{ spb.and(spb2); fail("should throw"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } } |
### Question:
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamPredicateBuilder or(Predicate predicate) throws IllegalStateException { if (predicate != StreamPredicateBuilder.this) { throw new IllegalStateException( "Illegal \"or\" statement expected: " + StreamPredicateBuilder.class.getSimpleName() + ", found: " + ((Objects.isNull(predicate)) ? "null" : predicate.getClass().getSimpleName())); } int index = predicateList.size() - 2; StreamPredicate first = predicateList.remove(index); StreamPredicate second = predicateList.remove(index); predicateList.add(StreamPredicates.or(first, second)); return this; } StreamPredicateBuilder(); Attribute.Name getAttribute(); void setAttribute(Attribute.Name attributeName); @Override boolean apply(Collection<Attribute> attributes); StreamComparison getComparison(); StreamPredicateBuilder and(StreamPredicate predicate); StreamPredicateBuilder or(Predicate predicate); @Override Comparison attribute(Attribute.Name name); @Override Predicate and(Predicate... predicates); @Override Predicate or(Predicate... predicates); }### Answer:
@Test public void testStreamPredicateBuilderOrWithMultiPredicate() { StreamPredicateBuilder spb = new StreamPredicateBuilder(); try{ spb.or(null, null); fail("should throw unsupported operation exception"); }catch(Exception e){ assertTrue(e instanceof UnsupportedOperationException); } }
@Test public void testOrWithDiffPredicateInstance(){ StreamPredicateBuilder spb = new StreamPredicateBuilder(); StreamPredicateBuilder spb2 = new StreamPredicateBuilder(); try{ spb.or(spb2); fail("should throw"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } }
@Test public void testOrWithNullPredicateInstance(){ StreamPredicateBuilder spb = new StreamPredicateBuilder(); StreamPredicateBuilder spb2 = null; try{ spb.or(spb2); fail("should throw"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } } |
### Question:
StreamPredicateBuilder implements Predicate, StreamPredicate { @Override public Comparison attribute(Attribute.Name name) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } StreamPredicateBuilder(); Attribute.Name getAttribute(); void setAttribute(Attribute.Name attributeName); @Override boolean apply(Collection<Attribute> attributes); StreamComparison getComparison(); StreamPredicateBuilder and(StreamPredicate predicate); StreamPredicateBuilder or(Predicate predicate); @Override Comparison attribute(Attribute.Name name); @Override Predicate and(Predicate... predicates); @Override Predicate or(Predicate... predicates); }### Answer:
@Test public void testStreamPredicateBuilderAttribute() { StreamPredicateBuilder spb = new StreamPredicateBuilder(); try{ spb.attribute(null); fail("should throw unsupported operation exception"); }catch(Exception e){ assertTrue(e instanceof UnsupportedOperationException); } } |
### Question:
GraphRelationshipMutation implements Mutation { @Override public Mutation deleteAttribute(Name name) { operatons.unsetAttributeValue(name); return this; } GraphRelationshipMutation(Relationship relationship,
OperationPipeline pipeline,
BatchMutation batchMutation); @Override Mutation setAttribute(Name name, Object value); @Override Mutation deleteAttribute(Name name); @Override com.intuit.ugc.api.BatchMutation ready(); @Override Mutation delete(); }### Answer:
@Test public void testDeleteAttribute(){ GraphRelationship graphRelationship = createGraphRelationship(); OperationPipeline pipeline = new OperationPipeline(); BatchMutation batchMutation = new MockBatchMutation(); GraphRelationshipMutation graphRelationshipMutation = new GraphRelationshipMutation(graphRelationship, pipeline, batchMutation ); Mutation deleteAttribute = graphRelationshipMutation.deleteAttribute(TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME); assertNotNull(deleteAttribute); } |
### Question:
StreamPredicateBuilder implements Predicate, StreamPredicate { public StreamComparison getComparison() { return new StreamComparison(this); } StreamPredicateBuilder(); Attribute.Name getAttribute(); void setAttribute(Attribute.Name attributeName); @Override boolean apply(Collection<Attribute> attributes); StreamComparison getComparison(); StreamPredicateBuilder and(StreamPredicate predicate); StreamPredicateBuilder or(Predicate predicate); @Override Comparison attribute(Attribute.Name name); @Override Predicate and(Predicate... predicates); @Override Predicate or(Predicate... predicates); }### Answer:
@Test public void getComparison(){ StreamPredicateBuilder spb = new StreamPredicateBuilder(); assertNotNull(spb.getComparison()); } |
### Question:
AbstractGraphPersistence implements Persistence { @Override public ID allocateID() { String id = ID_PREFIX + UUID.randomUUID(); return ID.valueOf(id); } protected AbstractGraphPersistence(GraphVisitor repository,
MutationExecutorFactory factory); @Override ID allocateID(); @Override Queries.LookupQuery lookup(); @Override Queries.GraphQuery queryGraph(); @Override Entity.Mutation prepareMutation(Entity entity); @Override Relationship.Mutation prepareMutation(Relationship relationship); @Override Predicate predicates(); @Override BatchMutation prepareBatchMutation(); }### Answer:
@Test public void testAllocateID(){ MockGraphPersistence graphPersistence = createGraphPersistence(); assertTrue(graphPersistence.allocateID() instanceof ID); } |
### Question:
AbstractGraphPersistence implements Persistence { @Override public Queries.LookupQuery lookup() { return new GraphLookUpQuery(repository); } protected AbstractGraphPersistence(GraphVisitor repository,
MutationExecutorFactory factory); @Override ID allocateID(); @Override Queries.LookupQuery lookup(); @Override Queries.GraphQuery queryGraph(); @Override Entity.Mutation prepareMutation(Entity entity); @Override Relationship.Mutation prepareMutation(Relationship relationship); @Override Predicate predicates(); @Override BatchMutation prepareBatchMutation(); }### Answer:
@Test public void testLookup(){ MockGraphPersistence graphPersistence = createGraphPersistence(); assertTrue(graphPersistence.lookup() instanceof GraphLookUpQuery); } |
### Question:
AbstractGraphPersistence implements Persistence { @Override public Queries.GraphQuery queryGraph() { return new GraphQueryImpl(repository); } protected AbstractGraphPersistence(GraphVisitor repository,
MutationExecutorFactory factory); @Override ID allocateID(); @Override Queries.LookupQuery lookup(); @Override Queries.GraphQuery queryGraph(); @Override Entity.Mutation prepareMutation(Entity entity); @Override Relationship.Mutation prepareMutation(Relationship relationship); @Override Predicate predicates(); @Override BatchMutation prepareBatchMutation(); }### Answer:
@Test public void testQueryGraph(){ MockGraphPersistence graphPersistence = createGraphPersistence(); assertTrue(graphPersistence.queryGraph() instanceof Queries.GraphQuery); } |
### Question:
GraphRelationshipMutation implements Mutation { @Override public com.intuit.ugc.api.BatchMutation ready() { if (this.delete) { DeleteRelationship deleteRelationship = new DeleteRelationship(relationship); pipeline.add(deleteRelationship); } else { UpdateRelationship updateRelationship = new UpdateRelationship(relationship, operatons); pipeline.add(updateRelationship); } return batchMutation; } GraphRelationshipMutation(Relationship relationship,
OperationPipeline pipeline,
BatchMutation batchMutation); @Override Mutation setAttribute(Name name, Object value); @Override Mutation deleteAttribute(Name name); @Override com.intuit.ugc.api.BatchMutation ready(); @Override Mutation delete(); }### Answer:
@Test public void testReady(){ GraphRelationship graphRelationship = createGraphRelationship(); OperationPipeline pipeline = new OperationPipeline(); BatchMutation batchMutation = new MockBatchMutation(); GraphRelationshipMutation graphRelationshipMutation = new GraphRelationshipMutation(graphRelationship, pipeline, batchMutation ); BatchMutation ready = graphRelationshipMutation.ready(); assertNotNull(ready); } |
### Question:
AbstractGraphPersistence implements Persistence { @Override public Predicate predicates() { return new GraphPredicate(); } protected AbstractGraphPersistence(GraphVisitor repository,
MutationExecutorFactory factory); @Override ID allocateID(); @Override Queries.LookupQuery lookup(); @Override Queries.GraphQuery queryGraph(); @Override Entity.Mutation prepareMutation(Entity entity); @Override Relationship.Mutation prepareMutation(Relationship relationship); @Override Predicate predicates(); @Override BatchMutation prepareBatchMutation(); }### Answer:
@Test public void testPredicate(){ MockGraphPersistence graphPersistence = createGraphPersistence(); assertTrue(graphPersistence.predicates() instanceof GraphPredicate); } |
### Question:
AbstractGraphPersistence implements Persistence { @Override public BatchMutation prepareBatchMutation() { return new GraphMutation(factory); } protected AbstractGraphPersistence(GraphVisitor repository,
MutationExecutorFactory factory); @Override ID allocateID(); @Override Queries.LookupQuery lookup(); @Override Queries.GraphQuery queryGraph(); @Override Entity.Mutation prepareMutation(Entity entity); @Override Relationship.Mutation prepareMutation(Relationship relationship); @Override Predicate predicates(); @Override BatchMutation prepareBatchMutation(); }### Answer:
@Test public void testPrepareBatchMutation(){ MockGraphPersistence graphPersistence = createGraphPersistence(); assertTrue(graphPersistence.prepareBatchMutation() instanceof BatchMutation); } |
### Question:
GraphPredicate implements Predicate { @Override public Comparison attribute(Name name) { return new GraphComparison( Preconditions.argumentNotNull(name,"name")); } GraphPredicate(); private GraphPredicate(Name name, Object value,
PredicateComparison pComparison); Name getName(); Object getValue(); PredicateComparison getpComparison(); PredicateOperation getpOperation(); Predicate getNextPredicate(); @Override Predicate and(Predicate... predicate); @Override Predicate or(Predicate... predicate); @Override Comparison attribute(Name name); }### Answer:
@Test public void testGraphPredicateComparison(){ Name name = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME; GraphPredicate graphPredicate = new GraphPredicate(); Comparison comparisonAttribute = graphPredicate.attribute(name); assertNotNull(comparisonAttribute); } |
### Question:
GraphPredicate implements Predicate { @Override public Predicate or(Predicate... predicate) { Preconditions.argumentNotNull(predicate,"predicate::Predicate"); Predicate root = predicate[0]; conditionOp(PredicateOperation.OR, predicate); return root; } GraphPredicate(); private GraphPredicate(Name name, Object value,
PredicateComparison pComparison); Name getName(); Object getValue(); PredicateComparison getpComparison(); PredicateOperation getpOperation(); Predicate getNextPredicate(); @Override Predicate and(Predicate... predicate); @Override Predicate or(Predicate... predicate); @Override Comparison attribute(Name name); }### Answer:
@Test public void testPredicateOr(){ GraphPredicate graphPredicate1 = new GraphPredicate(); GraphPredicate graphPredicate2 = new GraphPredicate(); Predicate andPredicate = graphPredicate1.or(graphPredicate2); assertEquals(andPredicate, graphPredicate2); } |
### Question:
EqualToPredicate implements StreamPredicate { @Override public boolean apply(Collection<Attribute> attributes) { return Objects.nonNull(attributeName) && Objects.nonNull(value) && attributes.stream() .anyMatch(attr -> attr.getName().equals(attributeName) && value.equals(attr.getValue(value.getClass())) ); } EqualToPredicate(); EqualToPredicate(Attribute.Name attributeName); EqualToPredicate(Attribute.Name attributeName, Object value); @Override boolean apply(Collection<Attribute> attributes); }### Answer:
@Test public void testEqualToPredicateInitWithoutParams(){ EqualToPredicate equalToPredicate = new EqualToPredicate(); Collection<Attribute> attributes = Collections.emptyList(); assertFalse(equalToPredicate.apply(attributes)); }
@Test public void testEqualToPredicateInitWithOnlyAttrName(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName); Collection<Attribute> attributes = Collections.emptyList(); assertFalse(equalToPredicate.apply(attributes)); }
@Test public void testEqualToPredicateInitWithAttrNameAndValueNonMatch(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName, "test-attr-value"); Collection<Attribute> attributes = Collections.emptyList(); assertFalse(equalToPredicate.apply(attributes)); }
@Test public void testEqualToPredicateInitWithAttrNameAndValueMatch(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); Object attributeValue = "test-attr-value"; EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName, attributeValue); GraphAttribute graphAttribute = new GraphAttribute(attributeName, attributeValue, new MockMetadata()); List<Attribute> attributes = new ArrayList<Attribute>( Arrays.asList(graphAttribute)); assertTrue(equalToPredicate.apply(attributes)); } |
### Question:
GraphQueryResult implements Query.Result { @Override public Entity getEntity() { return queryResult.getEntityResponse().size() > 0 ? queryResult.getEntityResponse().get(0) : null; } GraphQueryResult(
final QueryResult<Entity, Relationship> queryResult); @Override Entity getEntity(); @Override List<Entity> getEntities(); @Override Relationship getRelationship(); @Override List<Relationship> getRelationships(); }### Answer:
@Test public void testGetEntityWithEmptyList(){ CurrentOperationType currentOperation = CurrentOperationType.ENTITY; QueryResult<Entity, Relationship> queryResult = new QueryResultImpl(currentOperation); GraphQueryResult graphQueryResult = new GraphQueryResult(queryResult ); assertNull(graphQueryResult.getEntity()); }
@Test public void testGetEntityWithEntityList(){ CurrentOperationType currentOperation = CurrentOperationType.ENTITY; QueryResult<Entity, Relationship> queryResult = new QueryResultImpl(currentOperation); List<Entity> entityList = new ArrayList<Entity>(); GraphEntity builtEntity = getEntity(); entityList.add(builtEntity); queryResult.setEntityOpResponse(entityList ); GraphQueryResult graphQueryResult = new GraphQueryResult(queryResult ); assertNotNull(graphQueryResult.getEntity()); assertEquals(builtEntity, graphQueryResult.getEntity()); } |
### Question:
GraphQueryResult implements Query.Result { @Override public Relationship getRelationship() { return queryResult.getRelationshipResponse().size() > 0 ? queryResult.getRelationshipResponse().get(0) : null; } GraphQueryResult(
final QueryResult<Entity, Relationship> queryResult); @Override Entity getEntity(); @Override List<Entity> getEntities(); @Override Relationship getRelationship(); @Override List<Relationship> getRelationships(); }### Answer:
@Test public void testGetRealtionshipWithEmptyRelationshipList(){ CurrentOperationType currentOperation = CurrentOperationType.RELATIONHIP; QueryResult<Entity, Relationship> queryResult = new QueryResultImpl(currentOperation); GraphQueryResult graphQueryResult = new GraphQueryResult(queryResult ); assertNull(graphQueryResult.getRelationship()); } |
### Question:
GraphAttribute implements Attribute { @Override public Integer getInteger() { return TypeConverter.asInt(attributeValue); } <T> GraphAttribute(Name name, Object attributeValue,
Attribute.Metadata metadata); @Override Metadata getMetadata(); @Override Name getName(); @Override V getValue(Class<V> clazz); @Override Integer getInteger(); @Override Double getDouble(); @Override Boolean getBoolean(); @Override String getString(); @Override Instant getInstant(); @Override UUID getUUID(); }### Answer:
@Test public void testGraphAttributeCreationWithIntegerValue() { Name name = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME; Integer attributeValue = 1; Metadata metadata = new MockMetadata(); GraphAttribute graphAttribute = new GraphAttribute(name, attributeValue, metadata); assertValues(name, metadata, graphAttribute); assertEquals(graphAttribute.getInteger(), attributeValue); } |
### Question:
GraphAttribute implements Attribute { @Override public Double getDouble() { return TypeConverter.asDouble(attributeValue); } <T> GraphAttribute(Name name, Object attributeValue,
Attribute.Metadata metadata); @Override Metadata getMetadata(); @Override Name getName(); @Override V getValue(Class<V> clazz); @Override Integer getInteger(); @Override Double getDouble(); @Override Boolean getBoolean(); @Override String getString(); @Override Instant getInstant(); @Override UUID getUUID(); }### Answer:
@Test public void testGraphAttributeCreationWithDoubleValue() { Name name = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME; Double attributeValue = 1.1; Metadata metadata = new MockMetadata(); GraphAttribute graphAttribute = new GraphAttribute(name, attributeValue, metadata); assertValues(name, metadata, graphAttribute); assertEquals(graphAttribute.getDouble(), attributeValue); } |
### Question:
GraphAttribute implements Attribute { @Override public Boolean getBoolean() { return TypeConverter.asBoolean(attributeValue); } <T> GraphAttribute(Name name, Object attributeValue,
Attribute.Metadata metadata); @Override Metadata getMetadata(); @Override Name getName(); @Override V getValue(Class<V> clazz); @Override Integer getInteger(); @Override Double getDouble(); @Override Boolean getBoolean(); @Override String getString(); @Override Instant getInstant(); @Override UUID getUUID(); }### Answer:
@Test public void testGraphAttributeCreationWithBooleanValue() { Name name = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME; Boolean attributeValue = true; Metadata metadata = new MockMetadata(); GraphAttribute graphAttribute = new GraphAttribute(name, attributeValue, metadata); assertValues(name, metadata, graphAttribute); assertEquals(graphAttribute.getBoolean(), attributeValue); } |
### Question:
GraphAttribute implements Attribute { @Override public UUID getUUID() { return TypeConverter.convert(UUID.class,attributeValue); } <T> GraphAttribute(Name name, Object attributeValue,
Attribute.Metadata metadata); @Override Metadata getMetadata(); @Override Name getName(); @Override V getValue(Class<V> clazz); @Override Integer getInteger(); @Override Double getDouble(); @Override Boolean getBoolean(); @Override String getString(); @Override Instant getInstant(); @Override UUID getUUID(); }### Answer:
@Test public void testGraphAttributeCreationWithUUIDValue() { Name name = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME; UUID attributeValue = UUID.randomUUID(); Metadata metadata = new MockMetadata(); GraphAttribute graphAttribute = new GraphAttribute(name, attributeValue, metadata); assertValues(name, metadata, graphAttribute); assertEquals(graphAttribute.getUUID(), attributeValue); } |
### Question:
GraphAttribute implements Attribute { @Override public Instant getInstant() { return TypeConverter.convert(Instant.class,attributeValue); } <T> GraphAttribute(Name name, Object attributeValue,
Attribute.Metadata metadata); @Override Metadata getMetadata(); @Override Name getName(); @Override V getValue(Class<V> clazz); @Override Integer getInteger(); @Override Double getDouble(); @Override Boolean getBoolean(); @Override String getString(); @Override Instant getInstant(); @Override UUID getUUID(); }### Answer:
@Test public void testGraphAttributeCreationWithInstantValue() { Name name = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME; Instant attributeValue = Instant.now(); Metadata metadata = new MockMetadata(); GraphAttribute graphAttribute = new GraphAttribute(name, attributeValue, metadata); assertValues(name, metadata, graphAttribute); assertEquals(graphAttribute.getInstant(), attributeValue); } |
### Question:
OperationPipeline implements OperationList { public OperationPipeline() { } OperationPipeline(); @Override Operation getTailOperation(); @Override void add(Operation op); @Override OperationIterator iterator(); }### Answer:
@Test public void testOperationPipeline() { OperationPipeline operationPipeline = new OperationPipeline(); operationPipeline .add(new GetEntityByProperty(ATTR_PERSON_DISPLAY_NAME, "John")); operationPipeline.add(new SelectEntities(REL_CUSTOMER, Queries.GraphTraversal.Direction.OUT)); operationPipeline.add(new SelectRelationships(REL_CITY, Queries.GraphTraversal.Direction.IN)); operationPipeline.add(new GraphTerminalOperation()); OperationIterator vIterator = operationPipeline.iterator(); assertTrue(vIterator.hasNext()); assertTrue(vIterator.next() instanceof GetEntityByProperty); assertTrue(vIterator.next() instanceof SelectEntities); assertTrue(vIterator.next() instanceof SelectRelationships); assertTrue(vIterator.next() instanceof GraphTerminalOperation); } |
### Question:
OperationPipeline implements OperationList { @Override public Operation getTailOperation() { if (operations.size() > 0) { return operations.get(operations.size()-1); } else { return null; } } OperationPipeline(); @Override Operation getTailOperation(); @Override void add(Operation op); @Override OperationIterator iterator(); }### Answer:
@Test public void testOperationPipelineWithNoOperations(){ OperationPipeline operationPipeline = new OperationPipeline(); assertNull(operationPipeline.getTailOperation()); } |
### Question:
GetEntityByID implements Operation { public GetEntityByID(ID id) { super(); this.id = id; } GetEntityByID(ID id); ID getId(); @Override String toString(); }### Answer:
@Test public void testGetEntityById(){ ID id = Entity.ID.valueOf("test-id"); GetEntityByID getEntityById = new GetEntityByID(id); assertEquals(getEntityById.getId(), id); assertEquals(getEntityById.toString(), "Operation [Get Entity] Entity ID [test-id]"); } |
### Question:
GetEntityByProperty implements Operation { public GetEntityByProperty(Name name, String value) { super(); this.name = name; this.value = value; } GetEntityByProperty(Name name, String value); Name getName(); String getValue(); @Override String toString(); }### Answer:
@Test public void testGetEntityByProperty(){ Name name = Attribute.Name.valueOf("test-property"); GetEntityByProperty getEntityByProperty = new GetEntityByProperty(name, "test-property-val"); assertEquals(getEntityByProperty.getName(),name); assertEquals(getEntityByProperty.getValue(), "test-property-val"); assertEquals(getEntityByProperty.toString(), "Operation [Get Entity] Key [test-property] Value [test-property-val]"); } |
### Question:
GraphTerminalOperation implements TerminalOperation { public GraphTerminalOperation() { super(); nameList = new ArrayList<>(); namespaceList = new ArrayList<>(); } GraphTerminalOperation(); List<Name> getNameList(); List<Family> getNamespaceList(); @Override String toString(); @Override void include(Name name); @Override void include(Family namespace); }### Answer:
@Test public void testGraphTerminalOperation(){ GraphTerminalOperation graphTerminalOperation = new GraphTerminalOperation(); Name name = Attribute.Name.valueOf("test-name"); graphTerminalOperation.include(name); Family namespace = Attribute.Family.valueOf("test-namespace"); graphTerminalOperation.include(namespace); assertEquals(graphTerminalOperation.getNameList().get(0), name); assertEquals(graphTerminalOperation.getNamespaceList().get(0), namespace); assertEquals(graphTerminalOperation.toString(), "Graph Terminal Operation"); } |
### Question:
SelectEntities implements ContextOperation { public SelectEntities(Relationship.Name relationName, Direction direction) { super(); this.relationName = relationName; if (direction == null) { this.direction = Direction.IN_OUT; } else { this.direction = direction; } } SelectEntities(Relationship.Name relationName, Direction direction); Relationship.Name getRelationName(); Direction getDirection(); Predicate getPredicate(); @Override String toString(); @Override void condition(Predicate predicate); }### Answer:
@Test public void testSelectEntities(){ Name relationName = Relationship.Name.valueOf("test-relationship"); Direction direction = Direction.IN_OUT; SelectEntities selectEntities = new SelectEntities(relationName , direction ); assertEquals(selectEntities.getDirection(), direction); Predicate predicate = new GraphPredicate(); selectEntities.condition(predicate); assertEquals(selectEntities.getPredicate(), predicate); assertEquals(selectEntities.getRelationName(), relationName); assertEquals(selectEntities.toString(), "Operation [Select Entities] with relation label [test-relationship]"); try{ selectEntities.condition(predicate); fail("resetting predicate should throw exception"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } } |
### Question:
CreateEntity implements Operation { public CreateEntity(NewEntity newEntity) { super(); this.newEntity = newEntity; } CreateEntity(NewEntity newEntity); NewEntity newEntity(); @Override String toString(); }### Answer:
@Test public void testCreateEntity() { NewEntity newEntity = util.createNewEntity(TartanImplTestConstants.ATTR_PARENT_ID); CreateEntity createEntity = new CreateEntity(newEntity); NewEntity newEntity2 = createEntity.newEntity(); AssertJUnit.assertEquals(newEntity2.getEntityID(), newEntity.getEntityID()); String expectedToString = "Operation [Create Entity] Entity ID [" + newEntity.getEntityID().getRawID() + "]"; AssertJUnit.assertEquals(expectedToString, createEntity.toString()); } |
### Question:
UpdateEntity implements Operation { public UpdateEntity(Entity entity, GraphAttributeOperations operations) { super(); this.entity = entity; this.operations = operations; } UpdateEntity(Entity entity, GraphAttributeOperations operations); Entity getEntity(); GraphAttributeOperations getOperations(); @Override String toString(); }### Answer:
@Test public void testUpdateEntity(){ Entity entity = new GraphEntity.Builder().setID(Entity.ID.valueOf("test-entity")).build(); GraphAttributeOperations operations = new GraphAttributeOperations(); UpdateEntity updateEntity = new UpdateEntity(entity , operations ); assertEquals(updateEntity.getEntity(), entity); assertEquals(updateEntity.getOperations(), operations); assertEquals(updateEntity.toString(), "Operation [Update Entity] entity id [test-entity]"); } |
### Question:
UpdateRelationship implements Operation { public UpdateRelationship(Relationship relationship, GraphAttributeOperations operations) { super(); this.relationship = relationship; this.operations = operations; } UpdateRelationship(Relationship relationship,
GraphAttributeOperations operations); Relationship getRelationship(); GraphAttributeOperations getOperations(); @Override String toString(); }### Answer:
@Test public void testUpdateRelationship(){ Relationship relationship = new GraphRelationship.Builder().setName(Name.valueOf("test-relation")) .setSourceID(Entity.ID.valueOf("test-source")).setTargetID(Entity.ID.valueOf("test-target")).build(); GraphAttributeOperations operations = new GraphAttributeOperations(); UpdateRelationship updateRelationship = new UpdateRelationship(relationship , operations ); assertEquals(updateRelationship.getOperations(), operations); assertEquals(updateRelationship.getRelationship(), relationship); assertEquals(updateRelationship.toString(), "Operation [Update Relationship] source id [test-source] target id [test-target]"); } |
### Question:
GetBatchEntityByID implements Operation { public GetBatchEntityByID(List<Entity.ID> entityIDs) { super(); this.entityIDs = new ArrayList<Entity.ID>( Preconditions.collectionItemsNotNull(entityIDs, "entityIDs")); } GetBatchEntityByID(List<Entity.ID> entityIDs); List<Entity.ID> getEntityIDs(); @Override String toString(); }### Answer:
@Test public void testGetBatchEntityById(){ List<ID> entityIDs = new ArrayList<ID>(Arrays.asList(Entity.ID.valueOf("test-id-1"), Entity.ID.valueOf("test-id-2"))); GetBatchEntityByID getBatchEntityById = new GetBatchEntityByID(entityIDs); assertEquals(getBatchEntityById.getEntityIDs(), entityIDs); assertEquals(getBatchEntityById.toString(), "Operation [Get Entity] Entity ID [test-id-1, test-id-2]"); } |
### Question:
CreateRelationship implements Operation { public CreateRelationship(NewRelationship newRelationship) { super(); this.newRelationship = newRelationship; } CreateRelationship(NewRelationship newRelationship); NewRelationship newRelationship(); @Override String toString(); }### Answer:
@Test public void testCreateRelationship() { NewEntity sourceEntity = util.createNewEntity(TartanImplTestConstants.ATTR_CHILD_KEY); NewEntity targetEntity = util.createNewEntity(TartanImplTestConstants.ATTR_PARENT_KEY); NewRelationship newRelationship = NewRelationship .between(sourceEntity.getEntityID(), targetEntity.getEntityID()).withLabel(TartanImplTestConstants.ATTR_PARENT_CHILD_KEY).build(); CreateRelationship createRelationship = new CreateRelationship(newRelationship); assertEquals(newRelationship.getName(), createRelationship.newRelationship().getName()); assertEquals(sourceEntity.getEntityID(), createRelationship.newRelationship().getSourceID()); assertEquals(TartanImplTestConstants.ATTR_PARENT_CHILD_KEY.toString(), createRelationship.newRelationship().getName().toString()); String expectedRelationString = "Operation [Create Relationship] SOURCE ID [" + newRelationship.getSourceID() + "]" + " TARGET ID [" + newRelationship.getTargetID() + "]"; assertEquals(expectedRelationString, createRelationship.toString()); } |
### Question:
UUIDTypeConversion implements TypeConverter.Conversion<UUID> { @Override public Object[] getTypeKeys() { return new Object[] { UUID.class, UUID.class.getName() }; } @Override Object[] getTypeKeys(); @Override UUID convert(Object value); }### Answer:
@Test public void testGetTypeKeys(){ UUIDTypeConversion uuidTypeConverison = new UUIDTypeConversion(); Object[] typeKeys = uuidTypeConverison.getTypeKeys(); assertEquals(typeKeys[0] , UUID.class); assertEquals(typeKeys[1], UUID.class.getName()); } |
### Question:
GraphQueryImpl implements Queries.GraphQuery, Queries.GraphTraversal { @Override public Queries.GraphTraversal fromRootEntity(ID id) { Preconditions.argumentNotNull(id, "id"); pipeline.add(new GetEntityByID(id)); return this; } GraphQueryImpl(GraphVisitor repository); @Override Queries.GraphTraversal selectAdjacentEntitiesVia(
Relationship.Name name); @Override Queries.GraphTraversal selectAdjacentEntitiesVia(
Relationship.Name name, Direction direction); @Override Queries.GraphTraversal selectAdjacentRelationships(
Relationship.Name name); @Override Queries.GraphTraversal selectAdjacentRelationships(
Relationship.Name name, Direction direction); @Override Queries.GraphTraversal where(Predicate predicate); @Override Queries.GraphTraversal fromRootEntity(ID id); @Override Projection select(); }### Answer:
@Test public void testFromRootEntityWithNullId(){ GraphVisitor repository = new MockGraphVisitor(); GraphQueryImpl graphQueryImpl = new GraphQueryImpl(repository); try{ graphQueryImpl.fromRootEntity(null); Assert.fail("Should have thrown exception"); }catch(Exception e){ AssertJUnit.assertTrue(e instanceof IllegalArgumentException); AssertJUnit.assertEquals(e.getMessage(), "Parameter \"id\" cannot be null"); } }
@Test public void testFromRootEntityWithValidId(){ GraphVisitor repository = new MockGraphVisitor(); GraphQueryImpl graphQueryImpl = new GraphQueryImpl(repository); Entity.ID sourceEntityID = Entity.ID.valueOf("urn:entity:" + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "." + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "/" + UUID.randomUUID()); GraphTraversal fromRootEntity = graphQueryImpl.fromRootEntity(sourceEntityID); AssertJUnit.assertNotNull(fromRootEntity); } |
### Question:
AndPredicate implements StreamPredicate, CompoundPredicate { @Override public void setPredicates(StreamPredicate[] predicates) { if (Objects.isNull(this.predicates)) { this.predicates = predicates; } else { throw new IllegalStateException( "Cannot reset predicates in an AndPredicate after they have been already set"); } } AndPredicate(); AndPredicate(StreamPredicate... predicates); @Override StreamPredicate[] getPredicates(); @Override void setPredicates(StreamPredicate[] predicates); @Override boolean apply(Collection<Attribute> attributes); }### Answer:
@Test public void testAndPredicateSetTwice(){ StreamPredicate[] predicates = new StreamPredicate[0]; AndPredicate andPredicate = new AndPredicate(predicates); try{ andPredicate.setPredicates(predicates); fail("again setting predicates should throw"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } } |
### Question:
InstantTypeConversion implements TypeConverter.Conversion<Instant> { @Override public Object[] getTypeKeys() { return new Object[] { Instant.class, Instant.class.getName() }; } @Override Object[] getTypeKeys(); @Override Instant convert(Object value); }### Answer:
@Test public void testInstantType(){ InstantTypeConversion instantTypeConversion = new InstantTypeConversion(); Object[] typeKeys = instantTypeConversion.getTypeKeys(); assertEquals(typeKeys[0], Instant.class); assertEquals(typeKeys[1], Instant.class.getName()); } |
### Question:
GraphEntityMutation implements Entity.Mutation { @Override public ValueSpecifier<Mutation> withAttribute(Name name) { return new GraphValueChange( Preconditions.argumentNotNull(name,"name")); } GraphEntityMutation(Entity entity,
OperationPipeline assemblyLine,
BatchMutation batchMutation); @Override ValueSpecifier<Mutation> withAttribute(Name name); @Override Mutation deleteAttribute(Name name); @Override Mutation deleteAttributes(Attribute.Family namespace); @Override Mutation delete(); @Override com.intuit.ugc.api.BatchMutation ready(); }### Answer:
@Test public void testGraphEntityMutationWithNullAttribute() { GraphEntityMutation graphEntityMutation = createGraphEntityMutation(null); try{ graphEntityMutation.withAttribute(null); fail("Should throw exception if called with null attribute"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); } }
@Test public void testWithAttributeWhenProperAttributeIsPassed() { GraphEntityMutation graphEntityMutation = createGraphEntityMutation(null); ValueSpecifier<Mutation> graphValueChange = graphEntityMutation .withAttribute(TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME); assertNotNull(graphValueChange); } |
### Question:
GraphEntityMutation implements Entity.Mutation { @Override public Mutation deleteAttribute(Name name) { attributeOperatons.unsetAttributeValue( Preconditions.argumentNotNull(name,"name")); return this; } GraphEntityMutation(Entity entity,
OperationPipeline assemblyLine,
BatchMutation batchMutation); @Override ValueSpecifier<Mutation> withAttribute(Name name); @Override Mutation deleteAttribute(Name name); @Override Mutation deleteAttributes(Attribute.Family namespace); @Override Mutation delete(); @Override com.intuit.ugc.api.BatchMutation ready(); }### Answer:
@Test public void testDeleteAttributeWithNullAttribute() { GraphEntityMutation graphEntityMutation = createGraphEntityMutation(null); try{ graphEntityMutation.deleteAttribute(null); fail("Should throw exception if called with null attribute"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); } }
@Test public void testDeleteAttributeWithValidAttributeName(){ GraphEntityMutation graphEntityMutation = createGraphEntityMutation(null); Mutation deleteAttribute = graphEntityMutation .deleteAttribute(TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME); assertNotNull(deleteAttribute); } |
### Question:
GraphEntityMutation implements Entity.Mutation { @Override public Mutation deleteAttributes(Attribute.Family namespace) { return this; } GraphEntityMutation(Entity entity,
OperationPipeline assemblyLine,
BatchMutation batchMutation); @Override ValueSpecifier<Mutation> withAttribute(Name name); @Override Mutation deleteAttribute(Name name); @Override Mutation deleteAttributes(Attribute.Family namespace); @Override Mutation delete(); @Override com.intuit.ugc.api.BatchMutation ready(); }### Answer:
@Test public void testDeleteAttributes(){ GraphEntityMutation graphEntityMutation = createGraphEntityMutation(null); Mutation deleteAttribute = graphEntityMutation .deleteAttributes(TartanImplTestConstants.ATTR_DUMMY_FAMILY); assertNotNull(deleteAttribute); } |
### Question:
AndPredicate implements StreamPredicate, CompoundPredicate { @Override public boolean apply(Collection<Attribute> attributes) { for (StreamPredicate predicate : predicates) { if (!predicate.apply(attributes)){ return false; } } return true; } AndPredicate(); AndPredicate(StreamPredicate... predicates); @Override StreamPredicate[] getPredicates(); @Override void setPredicates(StreamPredicate[] predicates); @Override boolean apply(Collection<Attribute> attributes); }### Answer:
@Test public void testApplyPredicates(){ StreamPredicate[] predicates = new StreamPredicate[0]; AndPredicate andPredicate = new AndPredicate(predicates); Collection<Attribute> attributes = Collections.emptyList(); assertTrue(andPredicate.apply(attributes)); }
@Test public void testApplyToNullPredicates(){ StreamPredicate[] predicates = new StreamPredicate[1]; predicates[0] = new EqualToPredicate(); AndPredicate andPredicate = new AndPredicate(predicates); Collection<Attribute> attributes = Collections.emptyList(); assertFalse(andPredicate.apply(attributes)); } |
### Question:
GraphEntityMutation implements Entity.Mutation { @Override public com.intuit.ugc.api.BatchMutation ready() { if(this.delete){ DeleteEntity deleteEntity = new DeleteEntity(entity); pipeline.add(deleteEntity); }else{ UpdateEntity updateEntity = new UpdateEntity(entity,attributeOperatons); pipeline.add(updateEntity); } return batchMutation; } GraphEntityMutation(Entity entity,
OperationPipeline assemblyLine,
BatchMutation batchMutation); @Override ValueSpecifier<Mutation> withAttribute(Name name); @Override Mutation deleteAttribute(Name name); @Override Mutation deleteAttributes(Attribute.Family namespace); @Override Mutation delete(); @Override com.intuit.ugc.api.BatchMutation ready(); }### Answer:
@Test public void testReady(){ MutationExecutorFactory factory = new MockMutationExecuterFactory(); BatchMutation graphBatchMutation = new GraphMutation(factory ); GraphEntityMutation graphEntityMutation = createGraphEntityMutation(graphBatchMutation); BatchMutation graphBatchMutation2 = graphEntityMutation.ready(); assertNotNull(graphBatchMutation); assertEquals(graphBatchMutation2, graphBatchMutation); } |
### Question:
GraphMutation implements BatchMutation { @Override public BatchMutation createEntity(NewEntity newEntity) { Preconditions.argumentNotNull(newEntity, "newEntity"); CreateEntity createEntity = new CreateEntity(newEntity); pipeline.add(createEntity); return this; } @Inject GraphMutation(MutationExecutorFactory factory); @Override BatchMutation createEntity(NewEntity newEntity); @Override BatchMutation createRelationship(NewRelationship newRelationship); @Override OperationResult<Result> execute(); @Override Entity.Mutation withEntity(Entity entity); @Override Relationship.Mutation withRelationship(Relationship relationship); }### Answer:
@Test public void testCreateEntityWithNullEntity(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); try{ graphMutation.createEntity(null); fail("Should have thrown an exception with null entity"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"newEntity\" cannot be null"); } }
@Test public void testCreateEntityWithValidEntity(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); TartanImplTestUtil util = new TartanImplTestUtil(); NewEntity newEntity = util.createNewEntity(TartanImplTestConstants.ATTR_PARENT_ID); BatchMutation createEntity = graphMutation.createEntity(newEntity); assertNotNull(createEntity); } |
### Question:
GraphMutation implements BatchMutation { @Override public BatchMutation createRelationship(NewRelationship newRelationship) { Preconditions.argumentNotNull(newRelationship, "newRelationship"); CreateRelationship createRelationships = new CreateRelationship( newRelationship); pipeline.add(createRelationships); return this; } @Inject GraphMutation(MutationExecutorFactory factory); @Override BatchMutation createEntity(NewEntity newEntity); @Override BatchMutation createRelationship(NewRelationship newRelationship); @Override OperationResult<Result> execute(); @Override Entity.Mutation withEntity(Entity entity); @Override Relationship.Mutation withRelationship(Relationship relationship); }### Answer:
@Test public void testCreateRelationshipWithNullRelationship(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); try{ graphMutation.createRelationship(null); fail("Should have thrown an exception with null relationship"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"newRelationship\" cannot be null"); } }
@Test public void testCreateRelationshipWithValidRelationship(){ TartanImplTestUtil util = new TartanImplTestUtil(); NewEntity sourceEntity = util.createNewEntity(TartanImplTestConstants.ATTR_CHILD_KEY); NewEntity targetEntity = util.createNewEntity(TartanImplTestConstants.ATTR_PARENT_KEY); NewRelationship newRelationship = NewRelationship .between(sourceEntity.getEntityID(), targetEntity.getEntityID()).withLabel(TartanImplTestConstants.ATTR_PARENT_CHILD_KEY).build(); MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); BatchMutation createRelationship = graphMutation.createRelationship(newRelationship); assertNotNull(createRelationship); } |
### Question:
GraphMutation implements BatchMutation { @Override public OperationResult<Result> execute() { return () -> (GraphMutationResult) graphOperation.operationResult(); } @Inject GraphMutation(MutationExecutorFactory factory); @Override BatchMutation createEntity(NewEntity newEntity); @Override BatchMutation createRelationship(NewRelationship newRelationship); @Override OperationResult<Result> execute(); @Override Entity.Mutation withEntity(Entity entity); @Override Relationship.Mutation withRelationship(Relationship relationship); }### Answer:
@Test public void testExecute(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); OperationResult<Result> execute = graphMutation.execute(); assertNotNull(execute); } |
### Question:
GraphMutation implements BatchMutation { @Override public Entity.Mutation withEntity(Entity entity) { Preconditions.argumentNotNull(entity, "entity"); return new GraphEntityMutation(entity, pipeline, this); } @Inject GraphMutation(MutationExecutorFactory factory); @Override BatchMutation createEntity(NewEntity newEntity); @Override BatchMutation createRelationship(NewRelationship newRelationship); @Override OperationResult<Result> execute(); @Override Entity.Mutation withEntity(Entity entity); @Override Relationship.Mutation withRelationship(Relationship relationship); }### Answer:
@Test public void testWithEntityWhenEntityIsNull(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); try{ graphMutation.withEntity(null); fail("Should have thrown an exception with null entity"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"entity\" cannot be null"); } }
@Test public void testWithEntityWhenEntityIsNotNull(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); Mutation withEntity = graphMutation.withEntity(buildEntity()); assertNotNull(withEntity); } |
### Question:
Generator { public void setTemplateRootDir(File templateRootDir) { setTemplateRootDirs(new File[] { templateRootDir }); } Generator(); void setTemplateRootDir(File templateRootDir); void setTemplateRootDir(String templateRootDir); void setTemplateRootDirs(File... templateRootDirs); void setTemplateRootDirs(String... templateRootDirs); void addTemplateRootDir(File file); void addTemplateRootDir(String file); boolean isIgnoreTemplateGenerateException(); void setIgnoreTemplateGenerateException(
boolean ignoreTemplateGenerateException); boolean isCopyBinaryFile(); void setCopyBinaryFile(boolean isCopyBinaryFile); String getSourceEncoding(); void setSourceEncoding(String sourceEncoding); String getOutputEncoding(); void setOutputEncoding(String outputEncoding); void setIncludes(String includes); void setExcludes(String excludes); void setOutRootDir(String rootDir); String getOutRootDir(); void setRemoveExtensions(String removeExtensions); void deleteOutRootDir(); Generator generateBy(Map templateModel, Map filePathModel); Generator deleteBy(Map templateModel, Map filePathModel); }### Answer:
@Test public void test_setTemplateRootDir() throws Throwable { File templateRootDir = null; generator.setTemplateRootDir(templateRootDir); } |
### Question:
Generator { public void addTemplateRootDir(File file) { templateRootDirs.add(file); } Generator(); void setTemplateRootDir(File templateRootDir); void setTemplateRootDir(String templateRootDir); void setTemplateRootDirs(File... templateRootDirs); void setTemplateRootDirs(String... templateRootDirs); void addTemplateRootDir(File file); void addTemplateRootDir(String file); boolean isIgnoreTemplateGenerateException(); void setIgnoreTemplateGenerateException(
boolean ignoreTemplateGenerateException); boolean isCopyBinaryFile(); void setCopyBinaryFile(boolean isCopyBinaryFile); String getSourceEncoding(); void setSourceEncoding(String sourceEncoding); String getOutputEncoding(); void setOutputEncoding(String outputEncoding); void setIncludes(String includes); void setExcludes(String excludes); void setOutRootDir(String rootDir); String getOutRootDir(); void setRemoveExtensions(String removeExtensions); void deleteOutRootDir(); Generator generateBy(Map templateModel, Map filePathModel); Generator deleteBy(Map templateModel, Map filePathModel); }### Answer:
@Test public void test_addTemplateRootDir() throws Throwable { File f = new File("."); generator.addTemplateRootDir(f); } |
### Question:
Generator { public void setCopyBinaryFile(boolean isCopyBinaryFile) { this.isCopyBinaryFile = isCopyBinaryFile; } Generator(); void setTemplateRootDir(File templateRootDir); void setTemplateRootDir(String templateRootDir); void setTemplateRootDirs(File... templateRootDirs); void setTemplateRootDirs(String... templateRootDirs); void addTemplateRootDir(File file); void addTemplateRootDir(String file); boolean isIgnoreTemplateGenerateException(); void setIgnoreTemplateGenerateException(
boolean ignoreTemplateGenerateException); boolean isCopyBinaryFile(); void setCopyBinaryFile(boolean isCopyBinaryFile); String getSourceEncoding(); void setSourceEncoding(String sourceEncoding); String getOutputEncoding(); void setOutputEncoding(String outputEncoding); void setIncludes(String includes); void setExcludes(String excludes); void setOutRootDir(String rootDir); String getOutRootDir(); void setRemoveExtensions(String removeExtensions); void deleteOutRootDir(); Generator generateBy(Map templateModel, Map filePathModel); Generator deleteBy(Map templateModel, Map filePathModel); }### Answer:
@Test public void test_setCopyBinaryFile() throws Throwable { boolean isCopyBinaryFile = true; generator.setCopyBinaryFile(isCopyBinaryFile); } |
### Question:
Generator { public void setTemplateRootDir(File templateRootDir) { setTemplateRootDirs(new File[]{templateRootDir}); } Generator(); void setTemplateRootDir(File templateRootDir); void setTemplateRootDir(String templateRootDir); void setTemplateRootDirs(File... templateRootDirs); void setTemplateRootDirs(String... templateRootDirs); void addTemplateRootDir(File file); void addTemplateRootDir(String file); boolean isIgnoreTemplateGenerateException(); void setIgnoreTemplateGenerateException(boolean ignoreTemplateGenerateException); boolean isCopyBinaryFile(); void setCopyBinaryFile(boolean isCopyBinaryFile); String getSourceEncoding(); void setSourceEncoding(String sourceEncoding); String getOutputEncoding(); void setOutputEncoding(String outputEncoding); void setIncludes(String includes); void setExcludes(String excludes); void setOutRootDir(String rootDir); String getOutRootDir(); void setRemoveExtensions(String removeExtensions); void deleteOutRootDir(); Generator generateBy(Map templateModel,Map filePathModel); Generator deleteBy(Map templateModel,Map filePathModel); }### Answer:
@Test public void test_setTemplateRootDir() throws Throwable { File templateRootDir = null; generator.setTemplateRootDir(templateRootDir); } |
### Question:
Generator { public void addTemplateRootDir(File file) { templateRootDirs.add(file); } Generator(); void setTemplateRootDir(File templateRootDir); void setTemplateRootDir(String templateRootDir); void setTemplateRootDirs(File... templateRootDirs); void setTemplateRootDirs(String... templateRootDirs); void addTemplateRootDir(File file); void addTemplateRootDir(String file); boolean isIgnoreTemplateGenerateException(); void setIgnoreTemplateGenerateException(boolean ignoreTemplateGenerateException); boolean isCopyBinaryFile(); void setCopyBinaryFile(boolean isCopyBinaryFile); String getSourceEncoding(); void setSourceEncoding(String sourceEncoding); String getOutputEncoding(); void setOutputEncoding(String outputEncoding); void setIncludes(String includes); void setExcludes(String excludes); void setOutRootDir(String rootDir); String getOutRootDir(); void setRemoveExtensions(String removeExtensions); void deleteOutRootDir(); Generator generateBy(Map templateModel,Map filePathModel); Generator deleteBy(Map templateModel,Map filePathModel); }### Answer:
@Test public void test_addTemplateRootDir() throws Throwable { File f = new File("."); generator.addTemplateRootDir(f); } |
### Question:
Generator { public void setCopyBinaryFile(boolean isCopyBinaryFile) { this.isCopyBinaryFile = isCopyBinaryFile; } Generator(); void setTemplateRootDir(File templateRootDir); void setTemplateRootDir(String templateRootDir); void setTemplateRootDirs(File... templateRootDirs); void setTemplateRootDirs(String... templateRootDirs); void addTemplateRootDir(File file); void addTemplateRootDir(String file); boolean isIgnoreTemplateGenerateException(); void setIgnoreTemplateGenerateException(boolean ignoreTemplateGenerateException); boolean isCopyBinaryFile(); void setCopyBinaryFile(boolean isCopyBinaryFile); String getSourceEncoding(); void setSourceEncoding(String sourceEncoding); String getOutputEncoding(); void setOutputEncoding(String outputEncoding); void setIncludes(String includes); void setExcludes(String excludes); void setOutRootDir(String rootDir); String getOutRootDir(); void setRemoveExtensions(String removeExtensions); void deleteOutRootDir(); Generator generateBy(Map templateModel,Map filePathModel); Generator deleteBy(Map templateModel,Map filePathModel); }### Answer:
@Test public void test_setCopyBinaryFile() throws Throwable { boolean isCopyBinaryFile = true; generator.setCopyBinaryFile(isCopyBinaryFile); } |
### Question:
CategoryServiceImpl implements CategoryService { @Override public void saveCategory(Category category) { categoryRepository.save(category); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber); }### Answer:
@Test public void saveCategory() throws Exception { Category category = new Category(); category.setName("java"); category.setParentId("0"); category.setHasParent(false); category.setCreateTime(new Date()); category.setUpdateTime(new Date()); categoryService.saveCategory(category); } |
### Question:
CategoryServiceImpl implements CategoryService { @Override public void insertCategories(Iterable<Category> iterable) { categoryRepository.save(iterable); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber); }### Answer:
@Test public void insertCategories() throws Exception { List<Category> list = new ArrayList<>(); for (int i=0;i<100;i++){ Category category = new Category(); category.setName("java"+i); category.setParentId("0"+i); category.setHasParent(false); category.setCreateTime(new Date()); category.setUpdateTime(new Date()); list.add(category); } categoryService.insertCategories(list); } |
### Question:
CategoryServiceImpl implements CategoryService { @Override public void deleteCategoryById(Long id) { categoryRepository.delete(id); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber); }### Answer:
@Test public void deleteCategoryById() throws Exception { categoryService.deleteCategoryById(100L); } |
### Question:
CategoryServiceImpl implements CategoryService { @Override public void updateCategory(Category category) { categoryRepository.save(category); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber); }### Answer:
@Test public void updateCategory() throws Exception { Category category = categoryService.findCategoryById(2L); category.setName("修改你的名称"); categoryService.updateCategory(category); } |
### Question:
CategoryServiceImpl implements CategoryService { @Override public Iterable<Category> findAll() { return categoryRepository.findAll(); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber); }### Answer:
@Test public void findAll() throws Exception { Iterable<Category> all = categoryService.findAll(); for (Category category : all) { System.err.println(category.toString()); } } |
### Question:
CategoryServiceImpl implements CategoryService { @Override public Category findCategoryById(Long id) { return categoryRepository.findOne(id); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber); }### Answer:
@Test public void findCategoryById() throws Exception { Category category = categoryService.findCategoryById(99L); System.err.println(category.toString()); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.