2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ===================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.champ.event;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.assertTrue;
27 import java.io.IOException;
28 import java.util.Collection;
29 import java.util.HashMap;
31 import java.util.Optional;
32 import java.util.concurrent.ArrayBlockingQueue;
33 import java.util.concurrent.BlockingQueue;
34 import java.util.concurrent.TimeUnit;
35 import java.util.stream.Stream;
37 import org.junit.After;
38 import org.junit.Before;
39 import org.junit.Test;
40 import org.onap.aai.champ.ChampCapabilities;
41 import org.onap.aai.champ.event.AbstractLoggingChampGraph;
42 import org.onap.aai.champ.exceptions.ChampIndexNotExistsException;
43 import org.onap.aai.champ.exceptions.ChampMarshallingException;
44 import org.onap.aai.champ.exceptions.ChampObjectNotExistsException;
45 import org.onap.aai.champ.exceptions.ChampRelationshipNotExistsException;
46 import org.onap.aai.champ.exceptions.ChampSchemaViolationException;
47 import org.onap.aai.champ.exceptions.ChampUnmarshallingException;
48 import org.onap.aai.champ.model.ChampObject;
49 import org.onap.aai.champ.model.ChampObjectConstraint;
50 import org.onap.aai.champ.model.ChampObjectIndex;
51 import org.onap.aai.champ.model.ChampPartition;
52 import org.onap.aai.champ.model.ChampRelationship;
53 import org.onap.aai.champ.model.ChampRelationshipConstraint;
54 import org.onap.aai.champ.model.ChampRelationshipIndex;
55 import org.onap.aai.champ.model.ChampSchema;
56 import org.slf4j.Logger;
58 import com.att.nsa.cambria.client.CambriaPublisher;
59 import com.fasterxml.jackson.core.JsonParseException;
60 import com.fasterxml.jackson.databind.JsonMappingException;
63 public class AbstractLoggingChampGraphTest {
65 /** Event stream producer stub. */
66 private InMemoryPublisher producer;
68 /** In memory graph for testing purposes. */
69 private TestGraph testGraph;
73 * Perform any setup tasks that need to be done prior to each test.
78 // Instantiate an event stream producer stub to use in our tests.
79 producer = new InMemoryPublisher();
81 // Instantiate an 'in-memory' graph for test purposes.
82 Map<String, Object> graphProperties = new HashMap<String, Object>();
83 graphProperties.put("champ.event.stream.hosts", "myeventstreamhost");
84 graphProperties.put("champ.event.stream.batch-size", 1);
85 testGraph = new TestGraph(graphProperties, producer);
90 * Perform any cleanup that needs to be done after each test.
93 public void tearDown() {
95 // Close our stubbed producer and graph.
102 * Validates that store/replace/delete operation against vertices result in the expected events
103 * being published to the event stream.
105 * @throws ChampMarshallingException
106 * @throws ChampSchemaViolationException
107 * @throws ChampObjectNotExistsException
108 * @throws InterruptedException
109 * @throws JsonParseException
110 * @throws JsonMappingException
111 * @throws IOException
114 public void vertexOperationsTest() throws ChampMarshallingException,
115 ChampSchemaViolationException,
116 ChampObjectNotExistsException,
117 InterruptedException,
119 JsonMappingException,
122 // Create a vertex and store it in the graph data store.
123 ChampObject obj1 = ChampObject.create()
126 .withProperty("p1", "v1")
127 .withProperty("p2", "v2")
129 testGraph.storeObject(obj1);
131 // Retrieve the next event from the event stream and validate that it is what we expect.
132 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
133 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
134 assertTrue("Entity type for store event was not a vertex.", loggedEventStr.contains("vertex"));
136 // Create a new vertex based on the one that we already created.
137 ChampObject obj2 = ChampObject.create()
140 .withProperty("p3", "v3")
143 // Now, try doing a replace operation.
144 testGraph.replaceObject(obj2);
146 // Retrieve the next event from the event stream and validate that it is what we expect.
147 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
148 assertTrue("Expected REPLACE event.", loggedEventStr.contains("REPLACE"));
149 assertTrue("Entity type for store event was not a vertex.", loggedEventStr.contains("vertex"));
151 // Finally, delete the vertex.
152 testGraph.deleteObject("123");
154 // Retrieve the next event from the event stream and validate that it is what we expect.
155 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
156 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
157 assertTrue("Entity type for store event was not a vertex.", loggedEventStr.contains("vertex"));
162 * This test validates that performing vertex operations in the case where the data to be
163 * forwarded to the event stream is unavailable results in no event being generated, but
164 * does not otherwise create issues.
166 * @throws ChampMarshallingException
167 * @throws ChampSchemaViolationException
168 * @throws ChampObjectNotExistsException
169 * @throws InterruptedException
170 * @throws JsonParseException
171 * @throws JsonMappingException
172 * @throws IOException
175 public void vertexOperationsWithNullsTest() throws ChampMarshallingException,
176 ChampSchemaViolationException,
177 ChampObjectNotExistsException,
178 InterruptedException,
180 JsonMappingException,
183 // Setup our test graph to simulate failures to retrieve data from the graph data store.
184 testGraph.returnNulls();
186 // Create a vertex and store it in the graph data store.
187 ChampObject obj1 = ChampObject.create()
190 .withProperty("p1", "v1")
191 .withProperty("p2", "v2")
193 testGraph.storeObject(obj1);
195 // Check our simulated event stream to verify that an event log was produced.
196 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
198 // Validate that we did not get an event from the stream.
199 assertNull("Store vertex event should not have been logged to the event stream", loggedEventStr);
201 // Create a new vertex based on the one that we already created.
202 ChampObject obj2 = ChampObject.create()
205 .withProperty("p3", "v3")
208 // Now, try doing a replace operation.
209 testGraph.replaceObject(obj2);
211 // Check our simulated event stream to see if an event log was not produced.
212 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
214 // Validate that we did not get an event from the stream.
215 assertNull("Store vertex event should not have been logged to the event stream", loggedEventStr);
217 // Finally, delete the vertex.
218 testGraph.deleteObject("123");
220 // Check our simulated event stream to see if an event log was not produced.
221 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
223 // Validate that we did not get an event from the stream.
224 assertNull("Store vertex event should not have been logged to the event stream", loggedEventStr);
229 * Validates that store/replace/delete operation against edges result in the expected events
230 * being published to the event stream.
232 * @throws ChampMarshallingException
233 * @throws ChampSchemaViolationException
234 * @throws ChampObjectNotExistsException
235 * @throws InterruptedException
236 * @throws JsonParseException
237 * @throws JsonMappingException
238 * @throws IOException
239 * @throws ChampUnmarshallingException
240 * @throws ChampRelationshipNotExistsException
243 public void edgeOperationsTest() throws ChampMarshallingException,
244 ChampSchemaViolationException,
245 ChampObjectNotExistsException,
246 InterruptedException,
248 JsonMappingException,
250 ChampUnmarshallingException,
251 ChampRelationshipNotExistsException {
253 // Create two vertices to act as the end points of our edge.
254 ChampObject obj1 = ChampObject.create()
257 .withProperty("p1", "v1")
258 .withProperty("p2", "v2")
261 ChampObject obj2 = ChampObject.create()
264 .withProperty("p3", "v3")
267 // Now, create an edge object and write it to the graph data store.
268 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
269 .property("property-1", "value-1")
270 .property("property-2", "value-2")
272 testGraph.storeRelationship(rel);
274 // Retrieve the next event from the event stream and validate that it is what we expect.
275 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
276 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
277 assertTrue("Entity type for store event was not an edge.", loggedEventStr.contains("relationship"));
279 // Now, create another edge object based on the one we just wrote, and use it to perform
280 // a replace operation.
281 ChampRelationship rel2 = ChampRelationship.create()
284 .withProperty("property-3", "value-3")
286 testGraph.replaceRelationship(rel2);
288 // Retrieve the next event from the event stream and validate that it is what we expect.
289 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
290 assertTrue("Expected REPLACE event.", loggedEventStr.contains("REPLACE"));
291 assertTrue("Entity type for store event was not an edge.", loggedEventStr.contains("relationship"));
293 // Finally, delete our edge.
294 testGraph.deleteRelationship(rel2);
296 // Retrieve the next event from the event stream and validate that it is what we expect.
297 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
298 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
299 assertTrue("Entity type for store event was not an edge.", loggedEventStr.contains("relationship"));
304 * This test validates that performing edge operations in the case where the data to be
305 * forwarded to the event stream is unavailable results in no event being generated, but
306 * does not otherwise create issues.
308 * @throws ChampMarshallingException
309 * @throws ChampSchemaViolationException
310 * @throws ChampObjectNotExistsException
311 * @throws InterruptedException
312 * @throws JsonParseException
313 * @throws JsonMappingException
314 * @throws IOException
315 * @throws ChampUnmarshallingException
316 * @throws ChampRelationshipNotExistsException
319 public void edgeOperationsWithNullsTest() throws ChampMarshallingException,
320 ChampSchemaViolationException,
321 ChampObjectNotExistsException,
322 InterruptedException,
324 JsonMappingException,
326 ChampUnmarshallingException,
327 ChampRelationshipNotExistsException {
329 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
331 testGraph.returnNulls();
333 // Create two vertices to act as the endpoints of our edge.
334 ChampObject obj1 = ChampObject.create()
337 .withProperty("p1", "v1")
338 .withProperty("p2", "v2")
341 ChampObject obj2 = ChampObject.create()
344 .withProperty("p3", "v3")
347 // Now, create an edge object and write it to the graph data store.
348 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
349 .property("property-1", "value-1")
350 .property("property-2", "value-2")
352 testGraph.storeRelationship(rel);
354 // Check our simulated event stream to see if an event log was produced.
355 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
357 // Validate that we did not get an event from the stream.
358 assertNull("Store edge event should not have been logged to the event stream", loggedEventStr);
360 // Now, create another edge object based on the one we just wrote, and use it to perform
361 // a replace operation.
362 ChampRelationship rel2 = ChampRelationship.create()
365 .withProperty("property-3", "value-3")
367 testGraph.replaceRelationship(rel2);
369 // Check our simulated event stream to see if an event log was produced.
370 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
372 // Validate that we did not get an event from the stream.
373 assertNull("Store edge event should not have been logged to the event stream", loggedEventStr);
378 * Validates that store/replace/delete operation against partitions result in the expected events
379 * being published to the event stream.
381 * @throws ChampMarshallingException
382 * @throws ChampSchemaViolationException
383 * @throws ChampObjectNotExistsException
384 * @throws InterruptedException
385 * @throws JsonParseException
386 * @throws JsonMappingException
387 * @throws IOException
388 * @throws ChampUnmarshallingException
389 * @throws ChampRelationshipNotExistsException
392 public void partitionOperationsTest() throws ChampMarshallingException,
393 ChampSchemaViolationException,
394 ChampObjectNotExistsException,
395 InterruptedException,
397 JsonMappingException,
399 ChampUnmarshallingException,
400 ChampRelationshipNotExistsException {
402 // Create the vertices and edge objects that we need to create a partition.
403 ChampObject obj1 = ChampObject.create()
406 .withProperty("p1", "v1")
407 .withProperty("p2", "v2")
410 ChampObject obj2 = ChampObject.create()
413 .withProperty("p3", "v3")
416 // Now, create an edge object and write it to the graph data store.
417 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
418 .property("property-1", "value-1")
419 .property("property-2", "value-2")
422 // Now, create our partition object and store it in the graph.
423 ChampPartition partition = ChampPartition.create()
426 .withRelationship(rel)
428 testGraph.storePartition(partition);
430 // Retrieve the next event from the event stream and validate that it is what we expect.
431 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
432 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
433 assertTrue("Entity type for store event was not a partition.", loggedEventStr.contains("partition"));
435 // Now, delete our partition.
436 testGraph.deletePartition(partition);
438 // Retrieve the next event from the event stream and validate that it is what we expect.
439 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
440 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
441 assertTrue("Entity type for store event was not a partition.", loggedEventStr.contains("partition"));
446 * This test validates that performing partition operations in the case where the data to be
447 * forwarded to the event stream is unavailable results in no event being generated, but
448 * does not otherwise create issues.
450 * @throws ChampMarshallingException
451 * @throws ChampSchemaViolationException
452 * @throws ChampObjectNotExistsException
453 * @throws InterruptedException
454 * @throws JsonParseException
455 * @throws JsonMappingException
456 * @throws IOException
457 * @throws ChampUnmarshallingException
458 * @throws ChampRelationshipNotExistsException
461 public void partitionOperationsWithNullsTest() throws ChampMarshallingException,
462 ChampSchemaViolationException,
463 ChampObjectNotExistsException,
464 InterruptedException,
466 JsonMappingException,
468 ChampUnmarshallingException,
469 ChampRelationshipNotExistsException {
471 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
473 testGraph.returnNulls();
475 // Create all of the objects we need to create a partition, and store the partition
477 ChampObject obj1 = ChampObject.create()
480 .withProperty("p1", "v1")
481 .withProperty("p2", "v2")
484 ChampObject obj2 = ChampObject.create()
487 .withProperty("p3", "v3")
490 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
491 .property("property-1", "value-1")
492 .property("property-2", "value-2")
495 ChampPartition partition = ChampPartition.create()
498 .withRelationship(rel)
500 testGraph.storePartition(partition);
502 // Check our simulated event stream to see if an an event log was produced.
503 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
505 // Validate that we did not get an event from the stream.
506 assertNull("Store partition event should not have been logged to the event stream", loggedEventStr);
511 * Validates that store/replace/delete operation against vertex indexes result in the expected
512 * events being published to the event stream.
514 * @throws ChampMarshallingException
515 * @throws ChampSchemaViolationException
516 * @throws ChampObjectNotExistsException
517 * @throws InterruptedException
518 * @throws JsonParseException
519 * @throws JsonMappingException
520 * @throws IOException
521 * @throws ChampUnmarshallingException
522 * @throws ChampRelationshipNotExistsException
523 * @throws ChampIndexNotExistsException
526 public void indexOperationsTest() throws ChampMarshallingException,
527 ChampSchemaViolationException,
528 ChampObjectNotExistsException,
529 InterruptedException,
531 JsonMappingException,
533 ChampUnmarshallingException,
534 ChampRelationshipNotExistsException,
535 ChampIndexNotExistsException {
537 // Create an index object and store it in the graph.
538 ChampObjectIndex objIndex = ChampObjectIndex.create()
543 testGraph.storeObjectIndex(objIndex);
545 // Retrieve the next event from the event stream and validate that it is what we expect.
546 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
547 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
548 assertTrue("Entity type for store event was not a vertex index.", loggedEventStr.contains("objectIndex"));
550 // Now, delete our partition.
551 testGraph.deleteObjectIndex("myIndex");
553 // Retrieve the next event from the event stream and validate that it is what we expect.
554 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
555 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
556 assertTrue("Entity type for store event was not a vertex index.", loggedEventStr.contains("objectIndex"));
560 * This test validates that performing index operations in the case where the data to be
561 * forwarded to the event stream is unavailable results in no event being generated, but
562 * does not otherwise create issues.
564 * @throws ChampMarshallingException
565 * @throws ChampSchemaViolationException
566 * @throws ChampObjectNotExistsException
567 * @throws InterruptedException
568 * @throws JsonParseException
569 * @throws JsonMappingException
570 * @throws IOException
571 * @throws ChampUnmarshallingException
572 * @throws ChampRelationshipNotExistsException
573 * @throws ChampIndexNotExistsException
576 public void indexOperationsWithNullsTest() throws ChampMarshallingException,
577 ChampSchemaViolationException,
578 ChampObjectNotExistsException,
579 InterruptedException,
581 JsonMappingException,
583 ChampUnmarshallingException,
584 ChampRelationshipNotExistsException,
585 ChampIndexNotExistsException {
587 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
589 testGraph.returnNulls();
591 // Create an index object and store it in the graph.
592 ChampObjectIndex objIndex = ChampObjectIndex.create()
597 testGraph.storeObjectIndex(objIndex);
599 // Check our simulated event stream to see if an an event log was produced.
600 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
602 // Now, delete our index.
603 testGraph.deleteObjectIndex("myIndex");
605 // Check our simulated event stream to see if an an event log was produced.
606 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
608 // Validate that we did not get an event from the stream.
609 assertNull("Delete partition event should not have been logged to the event stream", loggedEventStr);
614 * This test validates that performing relationship index operations in the case where
615 * the data to be forwarded to the event stream is unavailable results in no event being
616 * generated, but does not otherwise create issues.
618 * @throws ChampMarshallingException
619 * @throws ChampSchemaViolationException
620 * @throws ChampObjectNotExistsException
621 * @throws InterruptedException
622 * @throws JsonParseException
623 * @throws JsonMappingException
624 * @throws IOException
625 * @throws ChampUnmarshallingException
626 * @throws ChampRelationshipNotExistsException
627 * @throws ChampIndexNotExistsException
630 public void relationshipIndexOperationsTest() throws ChampMarshallingException,
631 ChampSchemaViolationException,
632 ChampObjectNotExistsException,
633 InterruptedException,
635 JsonMappingException,
637 ChampUnmarshallingException,
638 ChampRelationshipNotExistsException,
639 ChampIndexNotExistsException {
641 // Create a relationship index object and store it in the graph.
642 ChampRelationshipIndex relIndex = ChampRelationshipIndex.create()
647 testGraph.storeRelationshipIndex(relIndex);
649 // Retrieve the next event from the event stream and validate that it is what we expect.
650 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
651 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
652 assertTrue("Entity type for store event was not a relationship index.", loggedEventStr.contains("relationshipIndex"));
654 // Now, delete our partition.
655 testGraph.deleteRelationshipIndex("myIndex");
657 // Retrieve the next event from the event stream and validate that it is what we expect.
658 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
659 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
660 assertTrue("Entity type for store event was not a relationship index.", loggedEventStr.contains("relationshipIndex"));
665 * This test validates that performing index operations in the case where the data to be
666 * forwarded to the event stream is unavailable results in no event being generated, but
667 * does not otherwise create issues.
669 * @throws ChampMarshallingException
670 * @throws ChampSchemaViolationException
671 * @throws ChampObjectNotExistsException
672 * @throws InterruptedException
673 * @throws JsonParseException
674 * @throws JsonMappingException
675 * @throws IOException
676 * @throws ChampUnmarshallingException
677 * @throws ChampRelationshipNotExistsException
678 * @throws ChampIndexNotExistsException
681 public void relationshipIndexOperationsWithNullsTest() throws ChampMarshallingException,
682 ChampSchemaViolationException,
683 ChampObjectNotExistsException,
684 InterruptedException,
686 JsonMappingException,
688 ChampUnmarshallingException,
689 ChampRelationshipNotExistsException,
690 ChampIndexNotExistsException {
692 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
694 testGraph.returnNulls();
696 // Create a relationship index object and store it in the graph.
697 ChampRelationshipIndex relIndex = ChampRelationshipIndex.create()
703 testGraph.storeRelationshipIndex(relIndex);
705 // Check our simulated event stream to see if an an event log was produced.
706 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
708 // Now, delete our index.
709 testGraph.deleteRelationshipIndex("myIndex");
711 // Check our simulated event stream to see if an event log was produced.
712 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
714 // Validate that we did not get an event from the stream.
715 assertNull("Delete partition event should not have been logged to the event stream", loggedEventStr);
720 * This is a simple graph stub that extends our {@link AbstractLoggingChampGraph} class which
721 * we can use to validate that log events get generated without worrying about having a real
724 private class TestGraph extends AbstractLoggingChampGraph {
726 /** If set, this causes simulated retrieve operations to fail. */
727 private boolean returnNulls = false;
730 protected TestGraph(Map<String, Object> properties, CambriaPublisher producer) {
733 setProducer(producer);
736 public void returnNulls() {
741 public void shutdown() {
743 publisherPool = null;
749 public ChampObject executeStoreObject(ChampObject object) throws ChampMarshallingException,
750 ChampSchemaViolationException,
751 ChampObjectNotExistsException {
760 public ChampObject executeReplaceObject(ChampObject object) throws ChampMarshallingException,
761 ChampSchemaViolationException,
762 ChampObjectNotExistsException {
771 public Optional<ChampObject> retrieveObject(Object key) throws ChampUnmarshallingException {
774 return(Optional.of(ChampObject.create()
779 return Optional.empty();
784 public void executeDeleteObject(Object key) throws ChampObjectNotExistsException {
789 public Stream<ChampObject> queryObjects(Map<String, Object> queryParams) {
790 // Not used by any tests.
795 public ChampRelationship executeStoreRelationship(ChampRelationship relationship)
796 throws ChampUnmarshallingException,
797 ChampMarshallingException,
798 ChampObjectNotExistsException,
799 ChampSchemaViolationException,
800 ChampRelationshipNotExistsException {
810 public ChampRelationship executeReplaceRelationship(ChampRelationship relationship)
811 throws ChampUnmarshallingException,
812 ChampMarshallingException,
813 ChampSchemaViolationException,
814 ChampRelationshipNotExistsException {
824 public Optional<ChampRelationship> retrieveRelationship(Object key) throws ChampUnmarshallingException {
825 // Not used by any tests.
830 public void executeDeleteRelationship(ChampRelationship relationship) throws ChampRelationshipNotExistsException {
831 // Not used by any tests.
835 public Stream<ChampRelationship> retrieveRelationships(ChampObject object)
836 throws ChampUnmarshallingException, ChampObjectNotExistsException {
838 // Not used by any tests.
843 public Stream<ChampRelationship> queryRelationships(Map<String, Object> queryParams) {
845 // Not used by any tests.
850 public ChampPartition executeStorePartition(ChampPartition partition)
851 throws ChampSchemaViolationException,
852 ChampRelationshipNotExistsException,
853 ChampMarshallingException,
854 ChampObjectNotExistsException {
864 public void executeDeletePartition(ChampPartition graph) {
865 // Not used by any tests.
869 public void executeStoreObjectIndex(ChampObjectIndex index) {
870 // Not used by any tests.
874 public Optional<ChampObjectIndex> retrieveObjectIndex(String indexName) {
877 return Optional.of(ChampObjectIndex.create()
879 .onType("doesnt matter")
880 .forField("doesnt matter")
883 return Optional.empty();
888 public Stream<ChampObjectIndex> retrieveObjectIndices() {
889 // Not used by any tests.
894 public void executeDeleteObjectIndex(String indexName) throws ChampIndexNotExistsException {
895 // Not used by any tests.
899 public void executeStoreRelationshipIndex(ChampRelationshipIndex index) {
900 // Not used by any tests.
904 public Optional<ChampRelationshipIndex> retrieveRelationshipIndex(String indexName) {
906 return Optional.of(ChampRelationshipIndex.create()
908 .onType("doesnt matter")
909 .forField("doesnt matter")
912 return Optional.empty();
917 public Stream<ChampRelationshipIndex> retrieveRelationshipIndices() {
918 // Not used by any tests.
923 public void executeDeleteRelationshipIndex(String indexName)
924 throws ChampIndexNotExistsException {
925 // Not used by any tests.
929 public void storeSchema(ChampSchema schema) throws ChampSchemaViolationException {
930 // Not used by any tests.
934 public ChampSchema retrieveSchema() {
935 // Not used by any tests.
940 public void updateSchema(ChampObjectConstraint objectConstraint)
941 throws ChampSchemaViolationException {
942 // Not used by any tests.
946 public void updateSchema(ChampRelationshipConstraint schema)
947 throws ChampSchemaViolationException {
948 // Not used by any tests.
952 public void deleteSchema() {
953 // Not used by any tests.
957 public ChampCapabilities capabilities() {
958 // Not used by any tests.
963 private class InMemoryPublisher implements CambriaPublisher {
965 public BlockingQueue<String> eventStream = new ArrayBlockingQueue<String>(50);
966 public BlockingQueue<String> failedMsgs = new ArrayBlockingQueue<String>(10);
968 private boolean failMode=false;
970 public void enterFailMode() {
975 public void logTo(Logger log) {
976 // Not used by any tests.
980 public void setApiCredentials(String apiKey, String apiSecret) {
981 // Not used by any tests.
985 public void clearApiCredentials() {
986 // Not used by any tests.
990 public void setHttpBasicCredentials(String username, String password) {
991 // Not used by any tests.
995 public void clearHttpBasicCredentials() {
996 // Not used by any tests.
1000 public int send(String partition, String msg) throws IOException {
1003 eventStream.add(msg);
1006 failedMsgs.add(msg);
1007 throw new IOException("nope");
1012 public int send(message msg) throws IOException {
1013 eventStream.add(msg.toString());
1018 public int send(Collection<message> msgs) throws IOException {
1019 for(message msg : msgs) {
1020 eventStream.add(msg.toString());
1026 public void close() {
1027 // Not used by any tests.