org.jmock.integration.junit4.JUnit4Mockery Java Examples
The following examples show how to use
org.jmock.integration.junit4.JUnit4Mockery.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntryParserImplTest.java From google-sites-liberation with Apache License 2.0 | 6 votes |
@Before public void before() { context = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; authorParser = context.mock(AuthorParser.class); contentParser = context.mock(ContentParser.class); dataParser = context.mock(DataParser.class); fieldParser = context.mock(FieldParser.class); summaryParser = context.mock(SummaryParser.class); titleParser = context.mock(TitleParser.class); updatedParser = context.mock(UpdatedParser.class); entryParser = new EntryParserImpl(authorParser, contentParser, dataParser, fieldParser, summaryParser, titleParser, updatedParser); try { document = DocumentBuilderFactory.newInstance() .newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { fail("Failure to create test document"); } }
Example #2
Source File: AbstractMondrianSchemaValidatorTestBase.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public void setUp() throws Exception { context = new JUnit4Mockery(); schema = loadSchema("/FoodMart.xml"); if (null == schema) { // end the test throw new RuntimeException("unable to load schema from file"); } conn = context.mock(Connection.class); meta = context.mock(DatabaseMetaData.class); rsSalesFact1997PrimaryKeys = context.mock(ResultSet.class, "rsSalesFact1997PrimaryKeys"); //$NON-NLS-1$ rsStorePrimaryKeys = context.mock(ResultSet.class, "rsStorePrimaryKeys"); //$NON-NLS-1$ rsSalesFact1997ForeignKey = context.mock(ResultSet.class, "rsSalesFact1997ForeignKey"); //$NON-NLS-1$ stmt = context.mock(Statement.class, "stmt"); rsCount = context.mock(ResultSet.class, "rsCount"); v1 = context.mock(MondrianSchemaValidator.class, "v1"); v2 = context.mock(MondrianSchemaValidator.class, "v2"); v3 = context.mock(MondrianSchemaValidator.class, "v3"); v4 = context.mock(MondrianSchemaValidator.class, "v4"); v5 = context.mock(MondrianSchemaValidator.class, "v5"); }
Example #3
Source File: SuddenSpeedChangeAnalysisTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void prepareTest() { context = new JUnit4Mockery(); injector = Guice.createInjector( new AbnormalAnalyzerAppTestModule(context) ); analysis = injector.getInstance(SuddenSpeedChangeAnalysis.class); statisticsService = injector.getInstance(AppStatisticsService.class); trackingService = injector.getInstance(EventEmittingTracker.class); eventRepository = injector.getInstance(EventRepository.class); // Create test data track = new Track(219000606); track.update(msg5); // Init static part }
Example #4
Source File: SafetyZoneServiceTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseBehind() { JUnit4Mockery context = new JUnit4Mockery(); Configuration configurationMock = context.mock(Configuration.class); context.checking(new Expectations() {{ oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH)); will(returnValue(2.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH)); will(returnValue(3.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND)); will(returnValue(0.75)); }}); SafetyZoneService sut = new SafetyZoneService(configurationMock); Ellipse safetyEllipse = sut.safetyZone(position, position, 90.0f, 0.0f, 100.0f, 15.0f, 65.0f, 5.5f); assertEquals(-15.0, safetyEllipse.getX(), 1e-6); assertEquals(-2.0, safetyEllipse.getY(), 1e-6); assertEquals(22.5, safetyEllipse.getBeta(), 1e-6); assertEquals(125.0, safetyEllipse.getAlpha(), 1e-6); assertEquals(0.0, safetyEllipse.getThetaDeg(), 1e-6); }
Example #5
Source File: SafetyZoneServiceTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseBreadth() { JUnit4Mockery context = new JUnit4Mockery(); Configuration configurationMock = context.mock(Configuration.class); context.checking(new Expectations() {{ oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH)); will(returnValue(2.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH)); will(returnValue(5.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND)); will(returnValue(0.25)); }}); SafetyZoneService sut = new SafetyZoneService(configurationMock); Ellipse safetyEllipse = sut.safetyZone(position, position, 90.0f, 0.0f, 100.0f, 15.0f, 65.0f, 5.5f); assertEquals(10.0, safetyEllipse.getX(), 1e-6); assertEquals(-2.0, safetyEllipse.getY(), 1e-6); assertEquals(37.5, safetyEllipse.getBeta(), 1e-6); assertEquals(100.0, safetyEllipse.getAlpha(), 1e-6); assertEquals(0.0, safetyEllipse.getThetaDeg(), 1e-6); }
Example #6
Source File: SafetyZoneServiceTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseLength() { JUnit4Mockery context = new JUnit4Mockery(); Configuration configurationMock = context.mock(Configuration.class); context.checking(new Expectations() {{ oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH)); will(returnValue(1.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH)); will(returnValue(3.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND)); will(returnValue(0.25)); }}); SafetyZoneService sut = new SafetyZoneService(configurationMock); Ellipse safetyEllipse = sut.safetyZone(position, position, 90.0f, 0.0f, 100.0f, 15.0f, 65.0f, 5.5f); assertEquals(-15.0, safetyEllipse.getX(), 1e-6); assertEquals(-2.0, safetyEllipse.getY(), 1e-6); assertEquals(22.5, safetyEllipse.getBeta(), 1e-6); assertEquals(75.0, safetyEllipse.getAlpha(), 1e-6); assertEquals(0.0, safetyEllipse.getThetaDeg(), 1e-6); }
Example #7
Source File: PacketHandlerImplTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void initNoAnalyses() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(CONFKEY_ANALYSIS_COG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SOG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_TYPESIZE_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_DRIFT_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_CLOSEENCOUNTER_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_FREEFLOW_ENABLED, false); final JUnit4Mockery context = new JUnit4Mockery(); Injector injectorMock = context.mock(Injector.class); context.checking(new Expectations() {{ }}); PacketHandlerImpl sut = new PacketHandlerImpl(configuration, injectorMock, null, null, null, null); Set<Analysis> analyses = sut.getAnalyses(); assertEquals(0, analyses.size()); }
Example #8
Source File: SiteExporterImplTest.java From google-sites-liberation with Apache License 2.0 | 6 votes |
@Before public void before() throws MalformedURLException { context = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; linkConverter = context.mock(AbsoluteLinkConverter.class); appendableFactory = context.mock(AppendableFactory.class); attachmentDownloader = new FakeDownloader(); entryStore = context.mock(EntryStore.class); entryStoreFactory = context.mock(EntryStoreFactory.class); feedProvider = context.mock(FeedProvider.class); pageExporter = context.mock(PageExporter.class); progressListener = context.mock(ProgressListener.class); revisionsExporter = context.mock(RevisionsExporter.class); siteExporter = new SiteExporterImpl(linkConverter, appendableFactory, attachmentDownloader, entryStoreFactory, feedProvider, pageExporter, revisionsExporter); sitesService = new SitesService(""); entries = Sets.newHashSet(); feedUrl = new URL("https://host/feeds/content/domain/webspace"); }
Example #9
Source File: PageExporterImplTest.java From google-sites-liberation with Apache License 2.0 | 6 votes |
@Before public void before() { context = new JUnit4Mockery(); ancestorLinksRenderer = context.mock(AncestorLinksRenderer.class); announcementsRenderer = context.mock(AnnouncementsRenderer.class); attachmentsRenderer = context.mock(AttachmentsRenderer.class); commentsRenderer = context.mock(CommentsRenderer.class); contentRenderer = context.mock(ContentRenderer.class); fileCabinetRenderer = context.mock(FileCabinetRenderer.class); listRenderer = context.mock(ListRenderer.class); subpageLinksRenderer = context.mock(SubpageLinksRenderer.class); titleRenderer = context.mock(TitleRenderer.class); exporter = new PageExporterImpl( ancestorLinksRenderer, announcementsRenderer, attachmentsRenderer, commentsRenderer, contentRenderer, fileCabinetRenderer, listRenderer, subpageLinksRenderer, titleRenderer); out = new StringBuilder(); entryStore = new InMemoryEntryStoreFactory().newEntryStore(); }
Example #10
Source File: SpeedOverGroundAnalysisTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void prepareTest() { context = new JUnit4Mockery(); // Mock dependencies trackingService = context.mock(EventEmittingTracker.class); statisticsService = context.mock(AppStatisticsService.class); statisticsRepository = context.mock(StatisticDataRepository.class); eventRepository = context.mock(EventRepository.class); behaviourManager = context.mock(BehaviourManager.class); configuration = new PropertiesConfiguration(); configuration.setProperty(CONFKEY_ANALYSIS_SOG_CELL_SHIPCOUNT_MIN, 1000); configuration.setProperty(CONFKEY_ANALYSIS_SOG_PD, 0.001); }
Example #11
Source File: EntryUploaderImplTest.java From google-sites-liberation with Apache License 2.0 | 5 votes |
@Before public void before() throws MalformedURLException { context = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; sitesService = context.mock(SitesService.class); entryInserter = context.mock(EntryInserter.class); entryProvider = context.mock(EntryProvider.class); entryUpdater = context.mock(EntryUpdater.class); feedUrl = new URL("http://sites.google.com/feeds/content/site/test"); entryUploader = new EntryUploaderImpl(entryInserter, entryProvider, entryUpdater); }
Example #12
Source File: AggListControllerTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
@Before public void setUp() throws Exception { controller = new AggListController(); context = new JUnit4Mockery() { { // only here to mock types that are not interfaces setImposteriser(ClassImposteriser.INSTANCE); } }; doc = context.mock(Document.class); container = context.mock(XulDomContainer.class); outputService = context.mock(OutputService.class); workspace = context.mock(Workspace.class); connModel = context.mock(ConnectionModel.class); schema = context.mock(Schema.class); uiExt = context.mock(AlgorithmUiExtension.class); algo = context.mock(Algorithm.class); aggregateSummaryModel = context.mock(AggregateSummaryModel.class); aggList = new AggListImpl(); controller.setOutputService(outputService); controller.setAggList(aggList); controller.setAlgorithmUiExtension(uiExt); controller.setAlgorithm(algo); // need some expectations here as setXulDomContainer calls getDocumentRoot on the container context.checking(new Expectations() { { one(container).getDocumentRoot(); will(returnValue(doc)); } }); controller.setXulDomContainer(container); controller.setWorkspace(workspace); controller.setConnectionModel(connModel); controller.setAggregateSummaryModel(aggregateSummaryModel); }
Example #13
Source File: ConnectionControllerTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
@Before public void setUp() throws Exception { controller = new ConnectionController(); context = new JUnit4Mockery(); doc = context.mock(Document.class); container = context.mock(XulDomContainer.class); dataHandler = context.mock(XulEventHandler.class); model = context.mock(ConnectionModel.class); controller.setConnectionModel(model); workspace = new Workspace(); controller.setWorkspace(workspace); outputService = context.mock(OutputService.class); controller.setOutputService(outputService); aSchemaProvider = context.mock(SchemaProviderUiExtension.class); cubeNames = Arrays.asList("testCube1", "testCube2"); providerModel = context.mock(SchemaModel.class); // need some expectations here as setXulDomContainer calls getDocumentRoot on the container context.checking(new Expectations() { { one(container).getDocumentRoot(); will(returnValue(doc)); allowing(doc).invokeLater(with(any(Runnable.class))); //don't care if the controller uses invokeLater or not } }); controller.setXulDomContainer(container); controller.setDataHandler(dataHandler); }
Example #14
Source File: ExportHandlerTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
@Before public void setUp() throws Exception { controller = new ExportHandler(); context = new JUnit4Mockery() { { // only here to mock types that are not interfaces setImposteriser(ClassImposteriser.INSTANCE); } }; doc = context.mock(Document.class); container = context.mock(XulDomContainer.class); outputService = context.mock(OutputService.class); executor = context.mock(SqlExecutor.class); aggList = new AggListImpl(); controller.setOutputService(outputService); controller.setAggList(aggList); controller.setDdlDmlExecutor(executor); // need some expectations here as setXulDomContainer calls getDocumentRoot on the container context.checking(new Expectations() { { one(container).getDocumentRoot(); will(returnValue(doc)); } }); controller.setXulDomContainer(container); }
Example #15
Source File: PathMacroManagerTest.java From consulo with Apache License 2.0 | 5 votes |
@Before public final void setupApplication() throws Exception { // in fact the test accesses extension points so it rather should be converted to a platform one assumeNotNull(ApplicationManager.getApplication()); context = new JUnit4Mockery(); context.setImposteriser(ClassImposteriser.INSTANCE); myApplication = context.mock(ApplicationEx.class, "application"); context.checking(new Expectations() { { allowing(myApplication).isUnitTestMode(); will(returnValue(false)); // some tests leave invokeLater()'s after them allowing(myApplication).invokeLater(with(any(Runnable.class)), with(any(ModalityState.class))); allowing(myApplication).runReadAction(with(any(Runnable.class))); will(new Action() { @Override public void describeTo(final Description description) { description.appendText("runs runnable"); } @Override @javax.annotation.Nullable public Object invoke(final Invocation invocation) throws Throwable { ((Runnable)invocation.getParameter(0)).run(); return null; } }); } }); }
Example #16
Source File: DefaultLineWrapPositionStrategyTest.java From consulo with Apache License 2.0 | 5 votes |
@Before public void setUp() { myStrategy = new DefaultLineWrapPositionStrategy(); myMockery = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; myProject = myMockery.mock(Project.class); }
Example #17
Source File: DocumentChangesCollectorTest.java From consulo with Apache License 2.0 | 5 votes |
@Before public void setUp() { myCollector = new DocumentChangesCollector(); buffer = new StringBuilder(TEXT); myCollector.setCollectChanges(true); myMockery = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; myDocument = myMockery.mock(Document.class); myMockery.checking(new Expectations() {{ allowing(myDocument).getTextLength(); will(returnValue(TEXT.length())); }}); }
Example #18
Source File: GuiProgressListenerTest.java From google-sites-liberation with Apache License 2.0 | 5 votes |
@Before public void before() { context = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; progressBar = context.mock(JProgressBar.class); textComponent = context.mock(JTextComponent.class); progressListener = new GuiProgressListener(progressBar, textComponent); }
Example #19
Source File: ShipSizeOrTypeEventTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void setUp() throws Exception { context = new JUnit4Mockery(); sessionFactory = context.mock(SessionFactory.class); session = context.mock(Session.class); }
Example #20
Source File: ShipTypeAndSizeAnalysisTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void prepareTest() { context = new JUnit4Mockery(); // Mock dependencies trackingService = context.mock(EventEmittingTracker.class); statisticsService = context.mock(AppStatisticsService.class); statisticsRepository = context.mock(StatisticDataRepository.class); eventRepository = context.mock(EventRepository.class); behaviourManager = context.mock(BehaviourManager.class); // Mock shipCount table statistics1 = ShipTypeAndSizeStatisticData.create(); statistics1.setValue((short) 2, (short) 0, "shipCount", 17); statistics1.setValue((short) 2, (short) 1, "shipCount", 87); statistics1.setValue((short) 2, (short) 2, "shipCount", 2); statistics1.setValue((short) 2, (short) 3, "shipCount", 618); statistics1.setValue((short) 3, (short) 2, "shipCount", 842); statistics1.setValue((short) 3, (short) 3, "shipCount", 954); statistics1.setValue((short) 4, (short) 2, "shipCount", 154); statistics1.setValue((short) 5, (short) 3, "shipCount", 34); // Mock shipCount table statistics2 = ShipTypeAndSizeStatisticData.create(); statistics2.setValue((short) 2, (short) 0, "shipCount", 17); statistics2.setValue((short) 2, (short) 1, "shipCount", 87); statistics2.setValue((short) 2, (short) 2, "shipCount", 2000); statistics2.setValue((short) 2, (short) 3, "shipCount", 618); statistics2.setValue((short) 3, (short) 2, "shipCount", 842); statistics2.setValue((short) 3, (short) 3, "shipCount", 954); statistics2.setValue((short) 4, (short) 2, "shipCount", 154); statistics2.setValue((short) 5, (short) 3, "shipCount", 34); configuration = new PropertiesConfiguration(); configuration.setProperty(CONFKEY_ANALYSIS_TYPESIZE_CELL_SHIPCOUNT_MIN, 1000); configuration.setProperty(CONFKEY_ANALYSIS_TYPESIZE_PD, 0.001); }
Example #21
Source File: DriftAnalysisTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void initDriftAnalysis() { context = new JUnit4Mockery(); injector = Guice.createInjector( new AbnormalAnalyzerAppTestModule(context) ); driftAnalysis = injector.getInstance(DriftAnalysis.class); }
Example #22
Source File: CourseOverGroundAnalysisTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void prepareTest() { context = new JUnit4Mockery(); // Mock dependencies trackingService = context.mock(EventEmittingTracker.class); statisticsService = context.mock(AppStatisticsService.class); statisticsRepository = context.mock(StatisticDataRepository.class); eventRepository = context.mock(EventRepository.class); behaviourManager = context.mock(BehaviourManager.class); configuration = new PropertiesConfiguration(); configuration.setProperty(CONFKEY_ANALYSIS_COG_CELL_SHIPCOUNT_MIN, 1000); configuration.setProperty(CONFKEY_ANALYSIS_COG_PD, 0.001); }
Example #23
Source File: RevisionExporterImplTest.java From google-sites-liberation with Apache License 2.0 | 5 votes |
@Before public void before() { context = new JUnit4Mockery(); listRenderer = context.mock(ListRenderer.class); revisionRenderer = context.mock(RevisionRenderer.class); titleRenderer = context.mock(TitleRenderer.class); revisionExporter = new RevisionExporterImpl( listRenderer, revisionRenderer, titleRenderer); out = new StringBuilder(); }
Example #24
Source File: SafetyZoneServiceTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void setup() { JUnit4Mockery context = new JUnit4Mockery(); Configuration configurationMock = context.mock(Configuration.class); context.checking(new Expectations() {{ oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH)); will(returnValue(2.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH)); will(returnValue(3.0)); oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND)); will(returnValue(0.25)); }}); sut = new SafetyZoneService(configurationMock); }
Example #25
Source File: BehaviourManagerImplTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void setUp() { context = new JUnit4Mockery(); trackingService = new EventEmittingTrackerImpl(Grid.createSize(200)); behaviourManager = new BehaviourManagerImpl(trackingService); track = new Track(12345678); track.update(1234567890L, Position.create(56, 12), 45.0f, 10.1f, 45.0f); testSubscriber = new EventBusSubscriber(); behaviourManager.registerSubscriber(testSubscriber); }
Example #26
Source File: PacketHandlerImplTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void initSelectedAnalyses() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(CONFKEY_ANALYSIS_COG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SOG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_TYPESIZE_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_DRIFT_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_ENABLED, true); configuration.addProperty(CONFKEY_ANALYSIS_CLOSEENCOUNTER_ENABLED, true); configuration.addProperty(CONFKEY_ANALYSIS_FREEFLOW_ENABLED, false); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH, 2.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH, 3.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND, 0.25); final JUnit4Mockery context = new JUnit4Mockery(); Injector injectorMock = context.mock(Injector.class); EventEmittingTracker trackingServiceMock = context.mock(EventEmittingTracker.class); SafetyZoneService safetyZoneService = new SafetyZoneService(configuration); context.checking(new Expectations() {{ ignoring(trackingServiceMock); oneOf(injectorMock).getInstance(with(SuddenSpeedChangeAnalysis.class)); will(returnValue(new SuddenSpeedChangeAnalysis(configuration, null, trackingServiceMock, null))); oneOf(injectorMock).getInstance(with(CloseEncounterAnalysis.class)); will(returnValue(new CloseEncounterAnalysis(configuration, null, trackingServiceMock, null, safetyZoneService))); }}); PacketHandlerImpl sut = new PacketHandlerImpl(configuration, injectorMock, null, null, null, null); Set<Analysis> analyses = sut.getAnalyses(); assertEquals(2, analyses.size()); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof CourseOverGroundAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof SpeedOverGroundAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof ShipTypeAndSizeAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof DriftAnalysis)); assertEquals(true, analyses.stream().anyMatch(a -> a instanceof SuddenSpeedChangeAnalysis)); assertEquals(true, analyses.stream().anyMatch(a -> a instanceof CloseEncounterAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof FreeFlowAnalysis)); }
Example #27
Source File: JpaEventRepositoryTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void init() { context = new JUnit4Mockery(); sessionFactory = context.mock(SessionFactory.class); session = context.mock(Session.class); query = context.mock(Query.class); eventRepository = new JpaEventRepository(sessionFactory, false); }
Example #28
Source File: CloseEncounterAnalysisTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 4 votes |
@Before public void setUp() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH, 2.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH, 3.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND, 0.25); context = new JUnit4Mockery(); trackingService = context.mock(EventEmittingTracker.class); statisticsService = context.mock(AppStatisticsService.class); eventRepository = context.mock(EventRepository.class); safetyZoneService = new SafetyZoneService(configuration); analysis = new CloseEncounterAnalysis(new PropertiesConfiguration(), statisticsService, trackingService, eventRepository, safetyZoneService); long timestamp = System.currentTimeMillis(); long tooOld = timestamp - maxTimestampDeviationMillis - 1; long old = timestamp - maxTimestampDeviationMillis + 1; long tooNew = timestamp + maxTimestampDeviationMillis + 1; long nyw = timestamp + maxTimestampDeviationMillis - 1; Position position = Position.create(56, 12); Position tooFarAway = Position.create(56.1, 12.1); assertTrue(position.distanceTo(tooFarAway, CoordinateSystem.CARTESIAN) > maxDistanceDeviationMeters); Position farAway = Position.create(56.014, 12.014); assertTrue(position.distanceTo(farAway, CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters); track = new Track(219000606); track.update(vessel1StaticPacket); track.update(timestamp, position, 90.0f, 10.0f, 90.0f); closeTrack = new Track(219002827); closeTrack.update(vessel2StaticPacket); closeTrack.update(timestamp - 40000, Position.create(56.1000, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp - 30000, Position.create(56.0800, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp - 20000, Position.create(56.0600, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp - 10000, Position.create(56.0400, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp, Position.create(56.00001, 12.0000), 180.0f, 10.0f, 180.0f); closeTrack.getTrackingReports().forEach( tr -> { tr.setProperty("event-certainty-CloseEncounterEvent", EventCertainty.LOWERED);}); assertTrue(closeTrack.getPosition().equals(Position.create(56.00001, 12.0000))); assertTrue(track.getPosition().distanceTo(closeTrack.getPosition(), CoordinateSystem.CARTESIAN) < 200); distantTrack = new Track(219000606); distantTrack.update(vessel1StaticPacket); distantTrack.update(timestamp, Position.create(57, 13), 90.0f, 10.0f, 90.0f); Track track1 = new Track(1); track1.update(tooOld, position, 90.0f, 10.0f, 90.0f); oldNearbyTrack = new Track(2); oldNearbyTrack.update(old, position, 90.0f, 10.0f, 90.0f); Track track3 = new Track(3); track3.update(tooNew, position, 90.0f, 10.0f, 90.0f); newNearbyTrack = new Track(3); newNearbyTrack.update(nyw, position, 90.0f, 10.0f, 90.0f); Track track4 = new Track(4); track4.update(timestamp, tooFarAway, 90.0f, 10.0f, 90.0f); distantNearbyTrack = new Track(5); distantNearbyTrack.update(timestamp, farAway, 90.0f, 10.0f, 90.0f); tracks = new HashSet<>(); tracks.add(track); tracks.add(track1); tracks.add(oldNearbyTrack); tracks.add(track3); tracks.add(track4); tracks.add(distantNearbyTrack); tracks.add(newNearbyTrack); }
Example #29
Source File: AbnormalAnalyzerAppTestModule.java From AisAbnormal with GNU Lesser General Public License v3.0 | 4 votes |
public AbnormalAnalyzerAppTestModule(JUnit4Mockery context) { this.context = context; }
Example #30
Source File: StandardArrangementEntryMatcherTest.java From consulo with Apache License 2.0 | 4 votes |
@Before public void setUp() { myMockery = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; }