@Test public void testLoadRepresentationsWithConfig() { try { // create config according to saved representation Representation mockRepresentation = RepresentationFactory.createLightweightRepresentation(); DbFilterConfig config = new DbFilterConfig(); config.addFormat(mockRepresentation.getFormat()); config.addOrigin(mockRepresentation.getModel().getOrigin()); config.addNotation(mockRepresentation.getNotation()); // load List<Representation> results = papi.loadRepresentations(config); Representation rep = results.get(0); Revision rev = rep.getRevision(); Model mod = rep.getModel(); assertTrue(results.size() > 0); assertEquals(rep.getFormat(), (mockRepresentation.getFormat())); assertEquals(rep.getNotation(), mockRepresentation.getNotation()); assertEquals(mod.getOrigin(), mockRepresentation.getModel().getOrigin()); assertEquals( mod.getLatestRevision(), rev); // because the mockRepresentation's model has only 1 revision } catch (Exception e) { fail(e.getMessage()); } }
@Test public void testLoadRepresentationsAsyncWithConfig() { DbFilterConfig conf = new DbFilterConfig(); conf.addNotation(Constants.NOTATION_BPMN2_0.toString()); DbListener dbl = new DbListener(); try { papi.loadRepresentationsAsync(conf, dbl); assertEquals(dbl.getResult(), 3); } catch (Exception e) { fail(e.getMessage()); } // no wrong input }