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.openecomp.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.openecomp.aai.champ.ChampCapabilities;
41 import org.openecomp.aai.champ.exceptions.ChampIndexNotExistsException;
42 import org.openecomp.aai.champ.exceptions.ChampMarshallingException;
43 import org.openecomp.aai.champ.exceptions.ChampObjectNotExistsException;
44 import org.openecomp.aai.champ.exceptions.ChampRelationshipNotExistsException;
45 import org.openecomp.aai.champ.exceptions.ChampSchemaViolationException;
46 import org.openecomp.aai.champ.exceptions.ChampUnmarshallingException;
47 import org.openecomp.aai.champ.model.ChampObject;
48 import org.openecomp.aai.champ.model.ChampObjectConstraint;
49 import org.openecomp.aai.champ.model.ChampObjectIndex;
50 import org.openecomp.aai.champ.model.ChampPartition;
51 import org.openecomp.aai.champ.model.ChampRelationship;
52 import org.openecomp.aai.champ.model.ChampRelationshipConstraint;
53 import org.openecomp.aai.champ.model.ChampRelationshipIndex;
54 import org.openecomp.aai.champ.model.ChampSchema;
55 import org.slf4j.Logger;
57 import com.att.nsa.cambria.client.CambriaPublisher;
58 import com.fasterxml.jackson.core.JsonParseException;
59 import com.fasterxml.jackson.databind.JsonMappingException;
62 public class AbstractLoggingChampGraphTest {
64 /** Event stream producer stub. */
65 private InMemoryPublisher producer;
67 /** In memory graph for testing purposes. */
68 private TestGraph testGraph;
72 * Perform any setup tasks that need to be done prior to each test.
77 // Instantiate an event stream producer stub to use in our tests.
78 producer = new InMemoryPublisher();
80 // Instantiate an 'in-memory' graph for test purposes.
81 Map<String, Object> graphProperties = new HashMap<String, Object>();
82 graphProperties.put("champ.event.stream.hosts", "myeventstreamhost");
83 graphProperties.put("champ.event.stream.batch-size", 1);
84 testGraph = new TestGraph(graphProperties, producer);
89 * Perform any cleanup that needs to be done after each test.
92 public void tearDown() {
94 // Close our stubbed producer and graph.
101 * Validates that store/replace/delete operation against vertices result in the expected events
102 * being published to the event stream.
104 * @throws ChampMarshallingException
105 * @throws ChampSchemaViolationException
106 * @throws ChampObjectNotExistsException
107 * @throws InterruptedException
108 * @throws JsonParseException
109 * @throws JsonMappingException
110 * @throws IOException
113 public void vertexOperationsTest() throws ChampMarshallingException,
114 ChampSchemaViolationException,
115 ChampObjectNotExistsException,
116 InterruptedException,
118 JsonMappingException,
121 // Create a vertex and store it in the graph data store.
122 ChampObject obj1 = ChampObject.create()
125 .withProperty("p1", "v1")
126 .withProperty("p2", "v2")
128 testGraph.storeObject(obj1);
130 // Retrieve the next event from the event stream and validate that it is what we expect.
131 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
132 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
133 assertTrue("Entity type for store event was not a vertex.", loggedEventStr.contains("vertex"));
135 // Create a new vertex based on the one that we already created.
136 ChampObject obj2 = ChampObject.create()
139 .withProperty("p3", "v3")
142 // Now, try doing a replace operation.
143 testGraph.replaceObject(obj2);
145 // Retrieve the next event from the event stream and validate that it is what we expect.
146 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
147 assertTrue("Expected REPLACE event.", loggedEventStr.contains("REPLACE"));
148 assertTrue("Entity type for store event was not a vertex.", loggedEventStr.contains("vertex"));
150 // Finally, delete the vertex.
151 testGraph.deleteObject("123");
153 // Retrieve the next event from the event stream and validate that it is what we expect.
154 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
155 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
156 assertTrue("Entity type for store event was not a vertex.", loggedEventStr.contains("vertex"));
161 * This test validates that performing vertex operations in the case where the data to be
162 * forwarded to the event stream is unavailable results in no event being generated, but
163 * does not otherwise create issues.
165 * @throws ChampMarshallingException
166 * @throws ChampSchemaViolationException
167 * @throws ChampObjectNotExistsException
168 * @throws InterruptedException
169 * @throws JsonParseException
170 * @throws JsonMappingException
171 * @throws IOException
174 public void vertexOperationsWithNullsTest() throws ChampMarshallingException,
175 ChampSchemaViolationException,
176 ChampObjectNotExistsException,
177 InterruptedException,
179 JsonMappingException,
182 // Setup our test graph to simulate failures to retrieve data from the graph data store.
183 testGraph.returnNulls();
185 // Create a vertex and store it in the graph data store.
186 ChampObject obj1 = ChampObject.create()
189 .withProperty("p1", "v1")
190 .withProperty("p2", "v2")
192 testGraph.storeObject(obj1);
194 // Check our simulated event stream to verify that an event log was produced.
195 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
197 // Validate that we did not get an event from the stream.
198 assertNull("Store vertex event should not have been logged to the event stream", loggedEventStr);
200 // Create a new vertex based on the one that we already created.
201 ChampObject obj2 = ChampObject.create()
204 .withProperty("p3", "v3")
207 // Now, try doing a replace operation.
208 testGraph.replaceObject(obj2);
210 // Check our simulated event stream to see if an event log was not produced.
211 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
213 // Validate that we did not get an event from the stream.
214 assertNull("Store vertex event should not have been logged to the event stream", loggedEventStr);
216 // Finally, delete the vertex.
217 testGraph.deleteObject("123");
219 // Check our simulated event stream to see if an event log was not produced.
220 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
222 // Validate that we did not get an event from the stream.
223 assertNull("Store vertex event should not have been logged to the event stream", loggedEventStr);
228 * Validates that store/replace/delete operation against edges result in the expected events
229 * being published to the event stream.
231 * @throws ChampMarshallingException
232 * @throws ChampSchemaViolationException
233 * @throws ChampObjectNotExistsException
234 * @throws InterruptedException
235 * @throws JsonParseException
236 * @throws JsonMappingException
237 * @throws IOException
238 * @throws ChampUnmarshallingException
239 * @throws ChampRelationshipNotExistsException
242 public void edgeOperationsTest() throws ChampMarshallingException,
243 ChampSchemaViolationException,
244 ChampObjectNotExistsException,
245 InterruptedException,
247 JsonMappingException,
249 ChampUnmarshallingException,
250 ChampRelationshipNotExistsException {
252 // Create two vertices to act as the end points of our edge.
253 ChampObject obj1 = ChampObject.create()
256 .withProperty("p1", "v1")
257 .withProperty("p2", "v2")
260 ChampObject obj2 = ChampObject.create()
263 .withProperty("p3", "v3")
266 // Now, create an edge object and write it to the graph data store.
267 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
268 .property("property-1", "value-1")
269 .property("property-2", "value-2")
271 testGraph.storeRelationship(rel);
273 // Retrieve the next event from the event stream and validate that it is what we expect.
274 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
275 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
276 assertTrue("Entity type for store event was not an edge.", loggedEventStr.contains("relationship"));
278 // Now, create another edge object based on the one we just wrote, and use it to perform
279 // a replace operation.
280 ChampRelationship rel2 = ChampRelationship.create()
283 .withProperty("property-3", "value-3")
285 testGraph.replaceRelationship(rel2);
287 // Retrieve the next event from the event stream and validate that it is what we expect.
288 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
289 assertTrue("Expected REPLACE event.", loggedEventStr.contains("REPLACE"));
290 assertTrue("Entity type for store event was not an edge.", loggedEventStr.contains("relationship"));
292 // Finally, delete our edge.
293 testGraph.deleteRelationship(rel2);
295 // Retrieve the next event from the event stream and validate that it is what we expect.
296 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
297 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
298 assertTrue("Entity type for store event was not an edge.", loggedEventStr.contains("relationship"));
303 * This test validates that performing edge operations in the case where the data to be
304 * forwarded to the event stream is unavailable results in no event being generated, but
305 * does not otherwise create issues.
307 * @throws ChampMarshallingException
308 * @throws ChampSchemaViolationException
309 * @throws ChampObjectNotExistsException
310 * @throws InterruptedException
311 * @throws JsonParseException
312 * @throws JsonMappingException
313 * @throws IOException
314 * @throws ChampUnmarshallingException
315 * @throws ChampRelationshipNotExistsException
318 public void edgeOperationsWithNullsTest() throws ChampMarshallingException,
319 ChampSchemaViolationException,
320 ChampObjectNotExistsException,
321 InterruptedException,
323 JsonMappingException,
325 ChampUnmarshallingException,
326 ChampRelationshipNotExistsException {
328 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
330 testGraph.returnNulls();
332 // Create two vertices to act as the endpoints of our edge.
333 ChampObject obj1 = ChampObject.create()
336 .withProperty("p1", "v1")
337 .withProperty("p2", "v2")
340 ChampObject obj2 = ChampObject.create()
343 .withProperty("p3", "v3")
346 // Now, create an edge object and write it to the graph data store.
347 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
348 .property("property-1", "value-1")
349 .property("property-2", "value-2")
351 testGraph.storeRelationship(rel);
353 // Check our simulated event stream to see if an event log was produced.
354 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
356 // Validate that we did not get an event from the stream.
357 assertNull("Store edge event should not have been logged to the event stream", loggedEventStr);
359 // Now, create another edge object based on the one we just wrote, and use it to perform
360 // a replace operation.
361 ChampRelationship rel2 = ChampRelationship.create()
364 .withProperty("property-3", "value-3")
366 testGraph.replaceRelationship(rel2);
368 // Check our simulated event stream to see if an event log was produced.
369 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
371 // Validate that we did not get an event from the stream.
372 assertNull("Store edge event should not have been logged to the event stream", loggedEventStr);
377 * Validates that store/replace/delete operation against partitions result in the expected events
378 * being published to the event stream.
380 * @throws ChampMarshallingException
381 * @throws ChampSchemaViolationException
382 * @throws ChampObjectNotExistsException
383 * @throws InterruptedException
384 * @throws JsonParseException
385 * @throws JsonMappingException
386 * @throws IOException
387 * @throws ChampUnmarshallingException
388 * @throws ChampRelationshipNotExistsException
391 public void partitionOperationsTest() throws ChampMarshallingException,
392 ChampSchemaViolationException,
393 ChampObjectNotExistsException,
394 InterruptedException,
396 JsonMappingException,
398 ChampUnmarshallingException,
399 ChampRelationshipNotExistsException {
401 // Create the vertices and edge objects that we need to create a partition.
402 ChampObject obj1 = ChampObject.create()
405 .withProperty("p1", "v1")
406 .withProperty("p2", "v2")
409 ChampObject obj2 = ChampObject.create()
412 .withProperty("p3", "v3")
415 // Now, create an edge object and write it to the graph data store.
416 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
417 .property("property-1", "value-1")
418 .property("property-2", "value-2")
421 // Now, create our partition object and store it in the graph.
422 ChampPartition partition = ChampPartition.create()
425 .withRelationship(rel)
427 testGraph.storePartition(partition);
429 // Retrieve the next event from the event stream and validate that it is what we expect.
430 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
431 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
432 assertTrue("Entity type for store event was not a partition.", loggedEventStr.contains("partition"));
434 // Now, delete our partition.
435 testGraph.deletePartition(partition);
437 // Retrieve the next event from the event stream and validate that it is what we expect.
438 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
439 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
440 assertTrue("Entity type for store event was not a partition.", loggedEventStr.contains("partition"));
445 * This test validates that performing partition operations in the case where the data to be
446 * forwarded to the event stream is unavailable results in no event being generated, but
447 * does not otherwise create issues.
449 * @throws ChampMarshallingException
450 * @throws ChampSchemaViolationException
451 * @throws ChampObjectNotExistsException
452 * @throws InterruptedException
453 * @throws JsonParseException
454 * @throws JsonMappingException
455 * @throws IOException
456 * @throws ChampUnmarshallingException
457 * @throws ChampRelationshipNotExistsException
460 public void partitionOperationsWithNullsTest() throws ChampMarshallingException,
461 ChampSchemaViolationException,
462 ChampObjectNotExistsException,
463 InterruptedException,
465 JsonMappingException,
467 ChampUnmarshallingException,
468 ChampRelationshipNotExistsException {
470 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
472 testGraph.returnNulls();
474 // Create all of the objects we need to create a partition, and store the partition
476 ChampObject obj1 = ChampObject.create()
479 .withProperty("p1", "v1")
480 .withProperty("p2", "v2")
483 ChampObject obj2 = ChampObject.create()
486 .withProperty("p3", "v3")
489 ChampRelationship rel = new ChampRelationship.Builder(obj1, obj2, "relationship")
490 .property("property-1", "value-1")
491 .property("property-2", "value-2")
494 ChampPartition partition = ChampPartition.create()
497 .withRelationship(rel)
499 testGraph.storePartition(partition);
501 // Check our simulated event stream to see if an an event log was produced.
502 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
504 // Validate that we did not get an event from the stream.
505 assertNull("Store partition event should not have been logged to the event stream", loggedEventStr);
510 * Validates that store/replace/delete operation against vertex indexes result in the expected
511 * events being published to the event stream.
513 * @throws ChampMarshallingException
514 * @throws ChampSchemaViolationException
515 * @throws ChampObjectNotExistsException
516 * @throws InterruptedException
517 * @throws JsonParseException
518 * @throws JsonMappingException
519 * @throws IOException
520 * @throws ChampUnmarshallingException
521 * @throws ChampRelationshipNotExistsException
522 * @throws ChampIndexNotExistsException
525 public void indexOperationsTest() throws ChampMarshallingException,
526 ChampSchemaViolationException,
527 ChampObjectNotExistsException,
528 InterruptedException,
530 JsonMappingException,
532 ChampUnmarshallingException,
533 ChampRelationshipNotExistsException,
534 ChampIndexNotExistsException {
536 // Create an index object and store it in the graph.
537 ChampObjectIndex objIndex = ChampObjectIndex.create()
542 testGraph.storeObjectIndex(objIndex);
544 // Retrieve the next event from the event stream and validate that it is what we expect.
545 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
546 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
547 assertTrue("Entity type for store event was not a vertex index.", loggedEventStr.contains("objectIndex"));
549 // Now, delete our partition.
550 testGraph.deleteObjectIndex("myIndex");
552 // Retrieve the next event from the event stream and validate that it is what we expect.
553 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
554 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
555 assertTrue("Entity type for store event was not a vertex index.", loggedEventStr.contains("objectIndex"));
559 * This test validates that performing index operations in the case where the data to be
560 * forwarded to the event stream is unavailable results in no event being generated, but
561 * does not otherwise create issues.
563 * @throws ChampMarshallingException
564 * @throws ChampSchemaViolationException
565 * @throws ChampObjectNotExistsException
566 * @throws InterruptedException
567 * @throws JsonParseException
568 * @throws JsonMappingException
569 * @throws IOException
570 * @throws ChampUnmarshallingException
571 * @throws ChampRelationshipNotExistsException
572 * @throws ChampIndexNotExistsException
575 public void indexOperationsWithNullsTest() throws ChampMarshallingException,
576 ChampSchemaViolationException,
577 ChampObjectNotExistsException,
578 InterruptedException,
580 JsonMappingException,
582 ChampUnmarshallingException,
583 ChampRelationshipNotExistsException,
584 ChampIndexNotExistsException {
586 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
588 testGraph.returnNulls();
590 // Create an index object and store it in the graph.
591 ChampObjectIndex objIndex = ChampObjectIndex.create()
596 testGraph.storeObjectIndex(objIndex);
598 // Check our simulated event stream to see if an an event log was produced.
599 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
601 // Now, delete our index.
602 testGraph.deleteObjectIndex("myIndex");
604 // Check our simulated event stream to see if an an event log was produced.
605 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
607 // Validate that we did not get an event from the stream.
608 assertNull("Delete partition event should not have been logged to the event stream", loggedEventStr);
613 * This test validates that performing relationship index operations in the case where
614 * the data to be forwarded to the event stream is unavailable results in no event being
615 * generated, but does not otherwise create issues.
617 * @throws ChampMarshallingException
618 * @throws ChampSchemaViolationException
619 * @throws ChampObjectNotExistsException
620 * @throws InterruptedException
621 * @throws JsonParseException
622 * @throws JsonMappingException
623 * @throws IOException
624 * @throws ChampUnmarshallingException
625 * @throws ChampRelationshipNotExistsException
626 * @throws ChampIndexNotExistsException
629 public void relationshipIndexOperationsTest() throws ChampMarshallingException,
630 ChampSchemaViolationException,
631 ChampObjectNotExistsException,
632 InterruptedException,
634 JsonMappingException,
636 ChampUnmarshallingException,
637 ChampRelationshipNotExistsException,
638 ChampIndexNotExistsException {
640 // Create a relationship index object and store it in the graph.
641 ChampRelationshipIndex relIndex = ChampRelationshipIndex.create()
646 testGraph.storeRelationshipIndex(relIndex);
648 // Retrieve the next event from the event stream and validate that it is what we expect.
649 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
650 assertTrue("Expected STORE event.", loggedEventStr.contains("STORE"));
651 assertTrue("Entity type for store event was not a relationship index.", loggedEventStr.contains("relationshipIndex"));
653 // Now, delete our partition.
654 testGraph.deleteRelationshipIndex("myIndex");
656 // Retrieve the next event from the event stream and validate that it is what we expect.
657 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
658 assertTrue("Expected DELETE event.", loggedEventStr.contains("DELETE"));
659 assertTrue("Entity type for store event was not a relationship index.", loggedEventStr.contains("relationshipIndex"));
664 * This test validates that performing index operations in the case where the data to be
665 * forwarded to the event stream is unavailable results in no event being generated, but
666 * does not otherwise create issues.
668 * @throws ChampMarshallingException
669 * @throws ChampSchemaViolationException
670 * @throws ChampObjectNotExistsException
671 * @throws InterruptedException
672 * @throws JsonParseException
673 * @throws JsonMappingException
674 * @throws IOException
675 * @throws ChampUnmarshallingException
676 * @throws ChampRelationshipNotExistsException
677 * @throws ChampIndexNotExistsException
680 public void relationshipIndexOperationsWithNullsTest() throws ChampMarshallingException,
681 ChampSchemaViolationException,
682 ChampObjectNotExistsException,
683 InterruptedException,
685 JsonMappingException,
687 ChampUnmarshallingException,
688 ChampRelationshipNotExistsException,
689 ChampIndexNotExistsException {
691 // Set up our graph to simulate a failure to retrieve some of the data we need to generate
693 testGraph.returnNulls();
695 // Create a relationship index object and store it in the graph.
696 ChampRelationshipIndex relIndex = ChampRelationshipIndex.create()
702 testGraph.storeRelationshipIndex(relIndex);
704 // Check our simulated event stream to see if an an event log was produced.
705 String loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
707 // Now, delete our index.
708 testGraph.deleteRelationshipIndex("myIndex");
710 // Check our simulated event stream to see if an event log was produced.
711 loggedEventStr = producer.eventStream.poll(5000, TimeUnit.MILLISECONDS);
713 // Validate that we did not get an event from the stream.
714 assertNull("Delete partition event should not have been logged to the event stream", loggedEventStr);
719 * This is a simple graph stub that extends our {@link AbstractLoggingChampGraph} class which
720 * we can use to validate that log events get generated without worrying about having a real
723 private class TestGraph extends AbstractLoggingChampGraph {
725 /** If set, this causes simulated retrieve operations to fail. */
726 private boolean returnNulls = false;
729 protected TestGraph(Map<String, Object> properties, CambriaPublisher producer) {
732 setProducer(producer);
735 public void returnNulls() {
740 public void shutdown() {
742 publisherPool = null;
748 public ChampObject executeStoreObject(ChampObject object) throws ChampMarshallingException,
749 ChampSchemaViolationException,
750 ChampObjectNotExistsException {
759 public ChampObject executeReplaceObject(ChampObject object) throws ChampMarshallingException,
760 ChampSchemaViolationException,
761 ChampObjectNotExistsException {
770 public Optional<ChampObject> retrieveObject(Object key) throws ChampUnmarshallingException {
773 return(Optional.of(ChampObject.create()
778 return Optional.empty();
783 public void executeDeleteObject(Object key) throws ChampObjectNotExistsException {
788 public Stream<ChampObject> queryObjects(Map<String, Object> queryParams) {
789 // Not used by any tests.
794 public ChampRelationship executeStoreRelationship(ChampRelationship relationship)
795 throws ChampUnmarshallingException,
796 ChampMarshallingException,
797 ChampObjectNotExistsException,
798 ChampSchemaViolationException,
799 ChampRelationshipNotExistsException {
809 public ChampRelationship executeReplaceRelationship(ChampRelationship relationship)
810 throws ChampUnmarshallingException,
811 ChampMarshallingException,
812 ChampSchemaViolationException,
813 ChampRelationshipNotExistsException {
823 public Optional<ChampRelationship> retrieveRelationship(Object key) throws ChampUnmarshallingException {
824 // Not used by any tests.
829 public void executeDeleteRelationship(ChampRelationship relationship) throws ChampRelationshipNotExistsException {
830 // Not used by any tests.
834 public Stream<ChampRelationship> retrieveRelationships(ChampObject object)
835 throws ChampUnmarshallingException, ChampObjectNotExistsException {
837 // Not used by any tests.
842 public Stream<ChampRelationship> queryRelationships(Map<String, Object> queryParams) {
844 // Not used by any tests.
849 public ChampPartition executeStorePartition(ChampPartition partition)
850 throws ChampSchemaViolationException,
851 ChampRelationshipNotExistsException,
852 ChampMarshallingException,
853 ChampObjectNotExistsException {
863 public void executeDeletePartition(ChampPartition graph) {
864 // Not used by any tests.
868 public void executeStoreObjectIndex(ChampObjectIndex index) {
869 // Not used by any tests.
873 public Optional<ChampObjectIndex> retrieveObjectIndex(String indexName) {
876 return Optional.of(ChampObjectIndex.create()
878 .onType("doesnt matter")
879 .forField("doesnt matter")
882 return Optional.empty();
887 public Stream<ChampObjectIndex> retrieveObjectIndices() {
888 // Not used by any tests.
893 public void executeDeleteObjectIndex(String indexName) throws ChampIndexNotExistsException {
894 // Not used by any tests.
898 public void executeStoreRelationshipIndex(ChampRelationshipIndex index) {
899 // Not used by any tests.
903 public Optional<ChampRelationshipIndex> retrieveRelationshipIndex(String indexName) {
905 return Optional.of(ChampRelationshipIndex.create()
907 .onType("doesnt matter")
908 .forField("doesnt matter")
911 return Optional.empty();
916 public Stream<ChampRelationshipIndex> retrieveRelationshipIndices() {
917 // Not used by any tests.
922 public void executeDeleteRelationshipIndex(String indexName)
923 throws ChampIndexNotExistsException {
924 // Not used by any tests.
928 public void storeSchema(ChampSchema schema) throws ChampSchemaViolationException {
929 // Not used by any tests.
933 public ChampSchema retrieveSchema() {
934 // Not used by any tests.
939 public void updateSchema(ChampObjectConstraint objectConstraint)
940 throws ChampSchemaViolationException {
941 // Not used by any tests.
945 public void updateSchema(ChampRelationshipConstraint schema)
946 throws ChampSchemaViolationException {
947 // Not used by any tests.
951 public void deleteSchema() {
952 // Not used by any tests.
956 public ChampCapabilities capabilities() {
957 // Not used by any tests.
962 private class InMemoryPublisher implements CambriaPublisher {
964 public BlockingQueue<String> eventStream = new ArrayBlockingQueue<String>(50);
965 public BlockingQueue<String> failedMsgs = new ArrayBlockingQueue<String>(10);
967 private boolean failMode=false;
969 public void enterFailMode() {
974 public void logTo(Logger log) {
975 // Not used by any tests.
979 public void setApiCredentials(String apiKey, String apiSecret) {
980 // Not used by any tests.
984 public void clearApiCredentials() {
985 // Not used by any tests.
989 public void setHttpBasicCredentials(String username, String password) {
990 // Not used by any tests.
994 public void clearHttpBasicCredentials() {
995 // Not used by any tests.
999 public int send(String partition, String msg) throws IOException {
1002 eventStream.add(msg);
1005 failedMsgs.add(msg);
1006 throw new IOException("nope");
1011 public int send(message msg) throws IOException {
1012 eventStream.add(msg.toString());
1017 public int send(Collection<message> msgs) throws IOException {
1018 for(message msg : msgs) {
1019 eventStream.add(msg.toString());
1025 public void close() {
1026 // Not used by any tests.