@SuppressWarnings({"rawtypes", "unchecked"}) public void testMonitorAndContinueWithoutTimeout() { ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); expect( schedulerMock.scheduleWithFixedDelay( anyObject(Runnable.class), anyLong(), anyLong(), anyObject(TimeUnit.class))) .andReturn(mockFuture); replay(mockFuture); replay(schedulerMock); CoutingEventHandler handler = new CoutingEventHandler(); EventBus eventBus = new EventBus(); eventBus.register(handler); AsyncMonitor<Object> monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), eventBus); assertNull(monitor.getFuture()); assertNull(monitor.getTimeout()); monitor.startMonitoring(null); assertNotNull(monitor.getFuture()); assertNull(monitor.getTimeout()); monitor.run(); assertEquals(handler.numCompletes, 0); assertEquals(handler.numFailures, 0); assertEquals(handler.numTimeouts, 0); verify(mockFuture); verify(schedulerMock); }
@Test public void testAcquireTokenAuthCode_ClientCredential() throws Exception { ctx = PowerMock.createPartialMock( AuthenticationContext.class, new String[] {"acquireTokenCommon"}, TestConfiguration.AAD_TENANT_ENDPOINT, true, service); PowerMock.expectPrivate( ctx, "acquireTokenCommon", EasyMock.isA(AdalAuthorizatonGrant.class), EasyMock.isA(ClientAuthentication.class), EasyMock.isA(ClientDataHttpHeaders.class)) .andReturn( new AuthenticationResult( "bearer", "accessToken", "refreshToken", new Date().getTime(), "idToken", null, false)); PowerMock.replay(ctx); Future<AuthenticationResult> result = ctx.acquireTokenByAuthorizationCode( "auth_code", new URI(TestConfiguration.AAD_DEFAULT_REDIRECT_URI), new ClientCredential("clientId", "clientSecret"), null); AuthenticationResult ar = result.get(); Assert.assertNotNull(ar); PowerMock.verifyAll(); }
@Test public void testCanParseBoxServerError() throws BoxRestException, IllegalStateException, IOException, BoxJSONException { BoxJSONParser jsonParser = new BoxJSONParser(new BoxResourceHub()); EasyMock.reset(boxResponse, response, entity); inputStream = new ByteArrayInputStream(jsonParser.convertBoxObjectToJSONString(error).getBytes()); EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response); EasyMock.expect(response.getEntity()).andStubReturn(entity); EasyMock.expect(entity.getContent()).andStubReturn(inputStream); EasyMock.expect(entity.isStreaming()).andStubReturn(false); EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response); EasyMock.expect(response.getStatusLine()).andStubReturn(statusLine); EasyMock.expect(statusLine.getStatusCode()).andStubReturn(statusCode); EasyMock.replay(boxResponse, response, entity, statusLine); ErrorResponseParser parser = new ErrorResponseParser(jsonParser); Object object = parser.parse(boxResponse); Assert.assertEquals(BoxServerError.class, object.getClass()); Assert.assertEquals( jsonParser.convertBoxObjectToJSONString(error), jsonParser.convertBoxObjectToJSONString(object)); EasyMock.verify(boxResponse, response, entity, statusLine); }
@Test public void testSetAction() { Action localAction = EasyMock.createMock(Action.class); EasyMock.replay(localAction); injecter.setAction(localAction); EasyMock.verify(localAction); }
/** TEST FORCE DELETING */ @Test public void testForceDelete() { Story story = new Story(); story.setId(1); Story child = new Story(); child.setParent(story); story.setChildren(new ArrayList<Story>(Arrays.asList(child))); story.setTasks(new HashSet<Task>(Arrays.asList(new Task(), new Task()))); story.setHourEntries( new HashSet<StoryHourEntry>( Arrays.asList(new StoryHourEntry(), new StoryHourEntry(), new StoryHourEntry()))); taskBusiness.delete(EasyMock.isA(Task.class), EasyMock.same(HourEntryHandlingChoice.DELETE)); expectLastCall().times(2); hourEntryBusiness.deleteAll(story.getHourEntries()); storyDAO.remove(1); replayAll(); storyBusiness.forceDelete(story); verifyAll(); assertNull("Child story's parent not null", child.getParent()); assertEquals("Parent story's children not empty", 0, story.getChildren().size()); }
@Test public void testForNonUniqueCodeListNotExisting() { String name = "TestCodeList"; String catId = "1"; String codeSystemId = "2"; String steward = "TestSteward"; String stewardOther = null; String oid = "3"; ManageCodeListDetailModel model1 = new ManageCodeListDetailModel(); model1.setName(name); model1.setCategory(catId); model1.setCodeSystem(codeSystemId); model1.setSteward(steward); model1.setStewardOther(stewardOther); model1.setOid(oid); // // editing a code list so that it matches a different existing code list // ManageCodeListDetailModel model = new ManageCodeListDetailModel(); model.setName(name); model.setCategory(catId); model.setSteward(steward); model.setCodeSystem(codeSystemId); CodeList existingCl = new CodeList(); String id = "id"; model.setExistingCodeList(false); existingCl.setId(id); EasyMock.expect(codeListDAO.getCodeList(model1, LoggedInUserUtil.getLoggedInUser())) .andReturn(existingCl); EasyMock.replay(codeListDAO); assertFalse(codeListService.isCodeListUnique(model)); }
@Test public void testEmptyHostmapUseCase() throws Exception { URL configUrl = TestUtils.getResourceUrl(this.getClass(), "empty-hostmap.txt"); UrlRewriteEnvironment environment = EasyMock.createNiceMock(UrlRewriteEnvironment.class); EasyMock.expect(environment.getResource("/WEB-INF/hostmap.txt")) .andReturn(configUrl) .anyTimes(); Resolver resolver = EasyMock.createNiceMock(Resolver.class); EasyMock.expect(resolver.resolve("host")) .andReturn(Arrays.asList("test-inbound-host")) .anyTimes(); EasyMock.replay(environment, resolver); UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create(); UrlRewriteRuleDescriptor rule = descriptor.addRule("test-rule"); rule.pattern("{*}://{host}:{*}/{**}?{**}"); UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep("rewrite"); rewrite.template("{*}://{$hostmap(host)}:{*}/{**}?{**}"); UrlRewriteProcessor rewriter = new UrlRewriteProcessor(); rewriter.initialize(environment, descriptor); Template input = Parser.parseLiteral( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value"); Template output = rewriter.rewrite(resolver, input, UrlRewriter.Direction.IN, null); // System.out.println( output ); assertThat(output, notNullValue()); assertThat(output.getHost().getFirstValue().getPattern(), is("test-inbound-host")); }
@Test public void testDeployProcess() throws PluginException { HashSet<RequestParameterType<?>> mandatoryProperties = new HashSet<>(); RequestParameterType<String> prop = new RequestParameterType<>("test", "test"); mandatoryProperties.add(prop); CanonicalProcessType cpf = new CanonicalProcessType(); AnnotationsType anf = new AnnotationsType(); expect(mockDeploymentPlugin.getNativeType()).andReturn("test"); expect(mockDeploymentPlugin.getName()).andReturn("test"); expect(mockDeploymentPlugin.getVersion()).andReturn("1.0"); PluginResultImpl result = new PluginResultImpl(); result.addPluginMessage("test"); expect( mockDeploymentPlugin.deployProcess( EasyMock.eq(cpf), EasyMock.eq(anf), EasyMock.anyObject(PluginRequest.class))) .andReturn(result); replay(mockDeploymentPlugin); List<PluginMessage> messages = myService.deployProcess("test", cpf, anf, mandatoryProperties); assertTrue(messages.size() == 1); verify(mockDeploymentPlugin); }
@SuppressWarnings("unchecked") @Test public void checkRPCCallSuccess() { // Setup Button button = GwtReflectionUtils.getPrivateFieldValue(composite, "button"); Label label = GwtReflectionUtils.getPrivateFieldValue(composite, "label"); service.createBean(EasyMock.eq("OCTO"), EasyMock.isA(AsyncCallback.class)); FooBean expected = new FooBean(); expected.setName("mocked"); expectServiceAndCallbackOnSuccess(expected); // replay all @Mock objects replay(); Assert.assertEquals("", label.getText()); // Test Browser.click(button); // Assert // verify all @Mock objects verify(); Assert.assertEquals("Bean \"mocked\" has been created", label.getText()); }
/** * Test de verification de deplacement du singe. * * @throws Exception expection technique de l'acces a la methode privee */ @Test public void testVerifierDeplacementSinge() throws Exception { final List<SingeErratique> erratiques = new ArrayList<SingeErratique>(); this.preparerAutreSingeHaut(); erratiques.add(this.singeErratiqueMock); EasyMock.expect(this.bandeDeSingesErratiquesMock.getSingesErratiques()) .andStubReturn(erratiques); EasyMock.replay(this.bandeDeSingesErratiquesMock); this.preparerPirateMock(2, 3); this.preparerIleMock(); // Accessibilité de la méthode privée final Method method = SingeErratique.class.getDeclaredMethod("verifierDeplacementSinge", int.class, int.class); method.setAccessible(true); // * Déplacement autorisé // Sur la terre Assert.assertFalse(((boolean) method.invoke(this.singeErratiqueIleMock, 2, 1))); // Pirate Assert.assertFalse(((boolean) method.invoke(this.singeErratiqueIleMock, 2, 3))); // * Déplacement interdit // Autre singe Assert.assertTrue(((boolean) method.invoke(this.singeErratiqueIleMock, 1, 2))); // Dans l'eau Assert.assertTrue(((boolean) method.invoke(this.singeErratiqueIleMock, 2, 0))); }
@Test public void testIteratorInSamePartition() throws Exception { EasyMock.expect( this.consumer.get( this.topic, new Partition("0-0"), 0L, this.maxSize, this.timeoutInMills, TimeUnit.MILLISECONDS)) .andReturn(new MessageIterator(this.topic, this.createMessageBuffer())) .once(); EasyMock.expect( this.consumer.get( this.topic, new Partition("0-0"), 25L, this.maxSize, this.timeoutInMills, TimeUnit.MILLISECONDS)) .andReturn(new MessageIterator(this.topic, this.createMessageBuffer())) .once(); this.control.replay(); Iterator<Message> it = this.browser.iterator(); if (it.hasNext()) { this.assertMsg(it.next()); } if (it.hasNext()) { this.assertMsg(it.next()); } this.control.verify(); MetaTopicBrowser.Itr mit = (MetaTopicBrowser.Itr) it; assertEquals(2, mit.partitions.size()); assertFalse(mit.partitions.contains(new Partition("0-0"))); }
@Test public void testStart() throws Exception { RoundRobinSchedulerStats stats = EasyMock.createMockBuilder(RoundRobinSchedulerStats.class) .withConstructor() .addMockedMethod("registerMBean") .addMockedMethod("createMovingAverage") .createStrictMock(); MovingAverage mavg = EasyMock.createStrictMock(MovingAverage.class); EasyMock.expect(stats.createMovingAverage()).andReturn(mavg); mavg.startTimer("RoundRobinAddMavg", stats.getAddMavgPeriod(), TimeUnit.MILLISECONDS); EasyMock.expectLastCall(); stats.registerMBean(); EasyMock.expectLastCall(); EasyMock.replay(stats, mavg); stats.start(); EasyMock.verify(stats, mavg); assertEquals("Mavg not set.", mavg, stats.m_addMavg); // with already called EasyMock.reset(stats, mavg); EasyMock.replay(stats, mavg); stats.start(); EasyMock.verify(stats, mavg); }
@Before public void setUp() { peekIterator = EasyMock.createMock(PeekingIterator.class); comparator = EasyMock.createMock(Comparator.class); binaryFn = EasyMock.createMock(BinaryFn.class); testingIterator = CombiningIterator.create(peekIterator, comparator, binaryFn); }
@SuppressWarnings({"rawtypes", "unchecked"}) public void testStartMonitoringWithTimeout() { ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); expect( schedulerMock.scheduleWithFixedDelay( anyObject(Runnable.class), anyLong(), anyLong(), anyObject(TimeUnit.class))) .andReturn(mockFuture); replay(mockFuture); replay(schedulerMock); AsyncMonitor<Object> monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), new EventBus()); assertNull(monitor.getFuture()); assertNull(monitor.getTimeout()); monitor.startMonitoring(100L); assertNotNull(monitor.getFuture()); assertNotNull(monitor.getTimeout()); assertTrue(monitor.getTimeout() > 100L); verify(mockFuture); verify(schedulerMock); }
private OpenStreetMapSimpleImporter createImporterThatThrows() { OpenStreetMapSimpleImporter importer = new OpenStreetMapSimpleImporter() { @Override public boolean shouldBeSkipped() { return false; } @Override public long getNumberOfLinesToProcess() { return 2L; } @Override protected void tearDown() { return; } }; // ImporterConfig config = new ImporterConfig(); // config.setOpenStreetMapDir(this.openStreetMapImporter.importerConfig.getOpenStreetMapDir()); IOpenStreetMapDao dao = EasyMock.createNiceMock(IOpenStreetMapDao.class); // now we simulate the fact that the dao should not be called EasyMock.expect(dao.save((OpenStreetMap) EasyMock.anyObject())) .andThrow(new RuntimeException("message")); EasyMock.replay(dao); importer.setOpenStreetMapDao(dao); importer.setImporterConfig(new ImporterConfig()); // importer.setTransactionManager(openStreetMapImporter.transactionManager); return importer; }
private Message mockMessage( String baseAddress, String pathInfo, String query, List<ClassResourceInfo> cris) throws Exception { Message m = new MessageImpl(); Exchange e = new ExchangeImpl(); e.put(Service.class, new JAXRSServiceImpl(cris)); m.setExchange(e); control.reset(); ServletDestination d = control.createMock(ServletDestination.class); EndpointInfo epr = new EndpointInfo(); epr.setAddress(baseAddress); d.getEndpointInfo(); EasyMock.expectLastCall().andReturn(epr).anyTimes(); Endpoint endpoint = new EndpointImpl(null, null, epr); e.put(Endpoint.class, endpoint); endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance()); e.setDestination(d); BindingInfo bi = control.createMock(BindingInfo.class); epr.setBinding(bi); bi.getProperties(); EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes(); m.put(Message.REQUEST_URI, pathInfo); m.put(Message.QUERY_STRING, query); m.put(Message.HTTP_REQUEST_METHOD, "GET"); control.replay(); return m; }
@Test public void testForNonUniqueGroupedCodeListExistingMatch() throws Exception { String name = "TestCodeList"; String catId = "1"; String steward = "TestSteward"; // // editing a code list so that it matches a different existing code list // ManageCodeListDetailModel model = new ManageCodeListDetailModel(); model.setName(name); model.setCategory(catId); model.setSteward(steward); ListObject codeList = new ListObject(); ListObject existingCl = new ListObject(); String id = "id"; model.setID(id); model.setExistingCodeList(true); existingCl.setId(id); EasyMock.expect(listObjectDAO.find(id)).andReturn(codeList); EasyMock.expect( listObjectDAO.getListObject(name, steward, catId, LoggedInUserUtil.getLoggedInUser())) .andReturn(existingCl); EasyMock.replay(listObjectDAO); assertTrue(codeListService.isGroupedCodeListUnique(model)); }
@Test public void testGetBuildTargetForAlias() throws IOException, NoSuchBuildTargetException { BuildTargetParser parser = EasyMock.createMock(BuildTargetParser.class); EasyMock.expect(parser.parse("//java/com/example:foo", ParseContext.fullyQualified())) .andReturn(BuildTargetFactory.newInstance("//java/com/example:foo")); EasyMock.expect(parser.parse("//java/com/example:bar", ParseContext.fullyQualified())) .andReturn(BuildTargetFactory.newInstance("//java/com/example:bar")); EasyMock.replay(parser); Reader reader = new StringReader( Joiner.on('\n') .join("[alias]", "foo = //java/com/example:foo", "bar = //java/com/example:bar")); BuckConfig config = createWithDefaultFilesystem(reader, parser); assertEquals("//java/com/example:foo", config.getBuildTargetForAlias("foo")); assertEquals("//java/com/example:bar", config.getBuildTargetForAlias("bar")); assertNull( "Invalid alias names, such as build targets, should be tolerated by this method.", config.getBuildTargetForAlias("//java/com/example:foo")); assertNull(config.getBuildTargetForAlias("baz")); Reader noAliasesReader = new StringReader(""); BuckConfig noAliasesConfig = createWithDefaultFilesystem(noAliasesReader, parser); assertNull(noAliasesConfig.getBuildTargetForAlias("foo")); assertNull(noAliasesConfig.getBuildTargetForAlias("bar")); assertNull(noAliasesConfig.getBuildTargetForAlias("baz")); EasyMock.verify(parser); }
@Test public void testTranslate() { String expectedLookUp = "lookUp"; String expectedKey = "foo"; String expectedLookUpKeyStr = "(" + expectedLookUp + ")" + expectedKey; LookUpKey expectedLookUpKey = new LookUpKey(expectedLookUp, expectedKey, expectedLookUpKeyStr); String expectedValue = "bar"; Property property = new Property(expectedLookUpKeyStr, expectedValue); LookUpKeyResolver lookUpKeyResolver = EasyMock.createStrictMock(LookUpKeyResolver.class); EasyMock.expect(lookUpKeyResolver.resolve(property.getKey())).andReturn(expectedLookUpKey); EasyMock.replay(lookUpKeyResolver); PropertyServiceImpl service = new PropertyServiceImpl(lookUpKeyResolver); ClearProperty clearProperty = service.translate(property); Assert.assertNotNull(clearProperty); Assert.assertNotNull(clearProperty.getLookUpKey()); Assert.assertNotNull(clearProperty.getKey()); Assert.assertNotNull(clearProperty.getValue()); Assert.assertNotNull(clearProperty.getLookUpKey().getKey()); Assert.assertNotNull(clearProperty.getLookUpKey().getLookUp()); Assert.assertEquals(clearProperty.getKey(), expectedKey); Assert.assertEquals(clearProperty.getValue(), expectedValue); Assert.assertEquals(clearProperty.getLookUpKey().getLookUp(), expectedLookUp); Assert.assertEquals(clearProperty.getLookUpKey().getLookUpKey(), expectedLookUpKeyStr); }
@Test public void testReferentialAliases() throws IOException, NoSuchBuildTargetException { BuildTargetParser parser = EasyMock.createMock(BuildTargetParser.class); EasyMock.expect(parser.parse("//java/com/example:foo", ParseContext.fullyQualified())) .andReturn(BuildTargetFactory.newInstance("//java/com/example:foo")); EasyMock.expect(parser.parse("//java/com/example:bar", ParseContext.fullyQualified())) .andReturn(BuildTargetFactory.newInstance("//java/com/example:bar")); EasyMock.replay(parser); Reader reader = new StringReader( Joiner.on('\n') .join( "[alias]", "foo = //java/com/example:foo", "bar = //java/com/example:bar", "foo_codename = foo", "", "# Do not delete these: automation builds require these aliases to exist!", "automation_foo = foo_codename", "automation_bar = bar")); BuckConfig config = createWithDefaultFilesystem(reader, parser); assertEquals("//java/com/example:foo", config.getBuildTargetForAlias("foo")); assertEquals("//java/com/example:bar", config.getBuildTargetForAlias("bar")); assertEquals("//java/com/example:foo", config.getBuildTargetForAlias("foo_codename")); assertEquals("//java/com/example:foo", config.getBuildTargetForAlias("automation_foo")); assertEquals("//java/com/example:bar", config.getBuildTargetForAlias("automation_bar")); assertNull(config.getBuildTargetForAlias("baz")); EasyMock.verify(parser); }
@Test public void testSetClassResource() { ClassResource cr = EasyMock.createMock(ClassResource.class); EasyMock.replay(cr); injecter.setClassResource(cr); EasyMock.verify(cr); }
@Test public void testIgnorePaths() throws IOException { ProjectFilesystem filesystem = EasyMock.createMock(ProjectFilesystem.class); EasyMock.expect(filesystem.getPathRelativizer()) .andReturn(Functions.<String>identity()) .times(2); BuildTargetParser parser = EasyMock.createMock(BuildTargetParser.class); EasyMock.replay(filesystem, parser); Reader reader = new StringReader( Joiner.on('\n').join("[project]", "ignore = .git, foo, bar/, baz//, a/b/c")); BuckConfig config = BuckConfig.createFromReader(reader, filesystem, parser, Platform.detect()); ImmutableSet<String> ignorePaths = config.getIgnorePaths(); assertEquals( "Should ignore paths, sans trailing slashes", ignorePaths, ImmutableSet.of( BuckConstant.BUCK_OUTPUT_DIRECTORY, ".idea", System.getProperty(BuckConfig.BUCK_BUCKD_DIR_KEY, ".buckd"), config.getCacheDir(), ".git", "foo", "bar", "baz", "a/b/c")); EasyMock.verify(filesystem, parser); }
@Test public void inloggenMetOnjuistWachtwoord() { Medewerker medewerker = new Medewerker(); medewerker.setIdentificatie("emailadres"); medewerker.setHashWachtwoord("wachtwoord"); try { EasyMock.expect(gebruikerRepository.zoek("emailadres")).andReturn(medewerker); } catch (NietGevondenException e1) { fail(); } HttpSession httpSession = EasyMock.createMock(HttpSession.class); EasyMock.expect(servletRequest.getSession()).andReturn(httpSession); EasyMock.expect(servletRequest.getRemoteAddr()).andReturn("1234"); EasyMock.expect(httpSession.getId()).andReturn("234"); replayAll(); try { gebruikerService.inloggen("emailadres", "foutwachtwoord", "false", servletRequest); fail("exception verwacht"); } catch (OnjuistWachtwoordException e) { // Verwacht.. } catch (LeegVeldException | NietGevondenException e) { fail(e.getMessage()); } verifyAll(); }
@Test public void testConfigurationEventAdded() throws Exception { String testPid = SecuredCommandConfigTransformer.PROXY_COMMAND_ACL_PID_PREFIX + "test123"; Configuration conf = EasyMock.createMock(Configuration.class); EasyMock.expect(conf.getPid()).andReturn(testPid).anyTimes(); EasyMock.replay(conf); ConfigurationAdmin cm = EasyMock.createMock(ConfigurationAdmin.class); EasyMock.expect(cm.listConfigurations(EasyMock.isA(String.class))).andReturn(null).anyTimes(); EasyMock.expect(cm.getConfiguration(testPid)).andReturn(conf).anyTimes(); EasyMock.replay(cm); final List<String> generateCalled = new ArrayList<String>(); SecuredCommandConfigTransformer scct = new SecuredCommandConfigTransformer() { @Override void generateServiceGuardConfig(Configuration config) throws IOException { generateCalled.add(config.getPid()); } }; scct.setConfigAdmin(cm); scct.init(); @SuppressWarnings("unchecked") ServiceReference<ConfigurationAdmin> cmRef = EasyMock.createMock(ServiceReference.class); EasyMock.replay(cmRef); ConfigurationEvent event = new ConfigurationEvent(cmRef, ConfigurationEvent.CM_UPDATED, null, testPid); assertEquals("Precondition", 0, generateCalled.size()); scct.configurationEvent(event); assertEquals(1, generateCalled.size()); assertEquals(testPid, generateCalled.iterator().next()); }
public void testShouldBuildJiraOkUsingElementAndFixVersionsWithMoreThanOneFixVersion() { Element e = createClassMock(Element.class); List<JiraVersion> fixVersions = createInterfaceMock(List.class); setupMockActualsForElement(e, "LLU-1", "Blah", "BlahStatus", "BlahResolution", "BlahType"); EasyMock.expect(fixVersions.get(0)).andReturn(TestObjects.Version_10); EasyMock.expect(fixVersions.size()).andReturn(2); replay(); JiraIssue jira = jiraBuilder.buildJira(e, fixVersions); verify(); assertJiraDetails( jira, "LLU-1", "Blah", "BlahStatus", "BlahResolution", "BlahType", new JiraVersion[] {TestObjects.Version_10}); assertEquals(1, jira.getFixVersions().size()); assertEquals(TestObjects.Version_10, jira.getFixVersions().get(0)); assertEquals(null, jira.getBuildNo()); }
@Test public void testReplace() { final AnalysesModel model = new AnalysesModel(); final MCMCPresentation inco1 = new MCMCPresentation(d_wrapper, "inco1"); final MCMCPresentation inco2 = new MCMCPresentation(d_wrapper, "inco2"); model.add(ModelType.Inconsistency, inco1); JUnitUtil.assertAllAndOnly( model.getModels(ModelType.Inconsistency), Collections.singleton(inco1)); TreeModelListener listener = EasyMock.createStrictMock(TreeModelListener.class); TreeModelEvent event1a = new TreeModelEvent( model, new Object[] {model.getRoot(), ModelType.Inconsistency}, new int[] {0}, new Object[] {inco2}); listener.treeNodesChanged(TreeModelEventMatcher.eqTreeModelEvent(event1a)); EasyMock.replay(listener); model.addTreeModelListener(listener); model.replace(ModelType.Inconsistency, inco1, inco2); EasyMock.verify(listener); JUnitUtil.assertAllAndOnly( model.getModels(ModelType.Inconsistency), Collections.singleton(inco2)); }
@Test public void testCreateMods() { ModsDefinition mods = new ModsDefinition(); NdkPeriodicalMapper mapper = new NdkPeriodicalMapper(); Context ctx = EasyMock.createMock(Context.class); EasyMock.expect(ctx.getPid()).andReturn("uuid:testId").anyTimes(); EasyMock.replay(ctx); mapper.createMods(mods, ctx); List<IdentifierDefinition> identifiersResult = mods.getIdentifier(); assertEquals(1, identifiersResult.size()); IdentifierDefinition idResult = identifiersResult.get(0); assertEquals("uuid", idResult.getType()); assertEquals("testId", idResult.getValue()); assertEquals(1, mods.getTypeOfResource().size()); assertEquals("text", mods.getTypeOfResource().get(0).getValue()); assertEquals(1, mods.getGenre().size()); assertEquals("title", mods.getGenre().get(0).getValue()); assertEquals(1, mods.getOriginInfo().size()); assertEquals(1, mods.getOriginInfo().get(0).getIssuance().size()); assertEquals(IssuanceDefinition.CONTINUING, mods.getOriginInfo().get(0).getIssuance().get(0)); assertEquals(0, mods.getOriginInfo().get(0).getPlace().size()); }
@Test public void testGetNearestCity_filterMunicipality() { ImporterConfig importerConfig = new ImporterConfig(); importerConfig.setGeonamesImporterEnabled(true); importerConfig.setOpenStreetMapFillIsIn(true); OpenStreetMapSimpleImporter openStreetMapImporter = new OpenStreetMapSimpleImporter(); openStreetMapImporter.setImporterConfig(importerConfig); final String cityName = "cityName"; final Integer population = 123; final City city = new City(); city.setName(cityName); city.setPopulation(population); ICityDao citydao = EasyMock.createMock(ICityDao.class); Point location = GeolocHelper.createPoint(2F, 3F); String countryCode = "FR"; EasyMock.expect( citydao.getNearest(location, countryCode, true, OpenStreetMapSimpleImporter.DISTANCE)) .andReturn(city); EasyMock.replay(citydao); openStreetMapImporter.setCityDao(citydao); City actual = openStreetMapImporter.getNearestCity(location, countryCode, true); Assert.assertEquals(cityName, actual.getName()); Assert.assertEquals(population, actual.getPopulation()); EasyMock.verify(citydao); }
@Test public void testGetQueryNoCache() throws Exception { final PermissionsFilterCache cache = mockController.getMock(PermissionsFilterCache.class); final BooleanQuery generatedQuery = new BooleanQuery(); org.easymock.EasyMock.expect(cache.getQuery(theUser)).andReturn(null); cache.storeQuery(generatedQuery, theUser); org.easymock.EasyMock.expectLastCall(); replay(); final PermissionQueryFactory permissionQueryFactory = new PermissionQueryFactory() { public Query getQuery(com.atlassian.crowd.embedded.api.User searcher, int permissionId) { assertSame(theUser, searcher); assertEquals(Permissions.BROWSE, permissionId); return generatedQuery; } }; final PermissionsFilterGeneratorImpl generator = new PermissionsFilterGeneratorImpl(permissionQueryFactory) { @Override PermissionsFilterCache getCache() { return cache; } }; final Query result = generator.getQuery(theUser); assertSame(generatedQuery, result); }
public static FedoraAccessImpl prepareFedoraAccess(StatisticsAccessLog acLog) throws NoSuchMethodException, IOException, ParserConfigurationException, SAXException, LexerException { FedoraAccessImpl fa33 = createMockBuilder(FedoraAccessImpl.class) .withConstructor(KConfiguration.getInstance(), acLog) .addMockedMethod("getFedoraDescribeStream") .addMockedMethod("getRelsExt") .addMockedMethod("isImageFULLAvailable") .addMockedMethod("getDC") .addMockedMethod("getBiblioMods") .addMockedMethod( FedoraAccessImpl.class.getMethod("getKrameriusModelName", String.class)) .createMock(); EasyMock.expect(fa33.getFedoraDescribeStream()).andReturn(DataPrepare.fedoraProfile33()); DataPrepare.drobnustkyRelsExt(fa33); DataPrepare.drobnustkyWithIMGFULL(fa33); DataPrepare.drobnustkyDCS(fa33); DataPrepare.drobnustkyMODS(fa33); Set<String> keySet = DocumentServiceTest.MODELS_MAPPING.keySet(); for (String key : keySet) { String model = DocumentServiceTest.MODELS_MAPPING.get(key); PIDParser pidParser = new PIDParser(model); pidParser.disseminationURI(); String modelK4Name = pidParser.getObjectId(); EasyMock.expect(fa33.getKrameriusModelName(key)).andReturn(modelK4Name).anyTimes(); } return fa33; }