@Test public void findMergedAnnotationAttributesOnSubSubInheritedAnnotationInterface() { AnnotationAttributes attributes = findMergedAnnotationAttributes( SubSubInheritedAnnotationInterface.class, Transactional.class); assertNotNull("Should find @Transactional on SubSubInheritedAnnotationInterface", attributes); }
@Test public void testGetSelectedPodsEmpty() { PodList selectedPods = getClient().getSelectedPods(pod.getLabels()); assertNotNull(selectedPods); assertNotNull(selectedPods.getItems()); assertEquals(0, selectedPods.getItems().size()); }
@Test public void testGetSelectedPodsWithNonExistantLabel() throws Exception { PodList selectedPods = getClient().getSelectedPods(ImmutableMap.of("name", "no-match")); assertNotNull(selectedPods); assertNotNull(selectedPods.getItems()); assertEquals(0, selectedPods.getItems().size()); }
/** Test payInvoice(invoice) API call. */ @Test public void testPayInvoice() { // setup UserWS user = buildUser(PRANCING_PONY_ACCOUNT_TYPE); user.setId(api.createUser(user)); ItemTypeWS itemType = buildItemType(); itemType.setId(api.createItemCategory(itemType)); ItemDTOEx item = buildItem(itemType.getId(), api.getCallerCompanyId()); item.setId(api.createItem(item)); // testing System.out.println("Getting an invoice paid, and validating the payment."); OrderWS order = buildOrder(user.getId(), Arrays.asList(item.getId()), new BigDecimal("3.45")); Integer invoiceId = api.createOrderAndInvoice( order, OrderChangeBL.buildFromOrder(order, ORDER_CHANGE_STATUS_APPLY)); Integer orderId = api.getInvoiceWS(invoiceId).getOrders()[0]; PaymentAuthorizationDTOEx auth = api.payInvoice(invoiceId); assertNotNull("auth can not be null", auth); PaymentWS payment = api.getLatestPayment(user.getId()); assertNotNull("payment can not be null", payment); assertNotNull("auth in payment can not be null", payment.getAuthorizationId()); // cleanup api.deletePayment(auth.getPaymentId()); api.deleteInvoice(invoiceId); api.deleteOrder(orderId); api.deleteItem(item.getId()); api.deleteItemCategory(itemType.getId()); api.deleteUser(user.getId()); }
private MoveAllocationCommand getAllocationCommand() { String fromNodeId = null; String toNodeId = null; ShardRouting shardToBeMoved = null; ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().get(); for (RoutingNode routingNode : clusterStateResponse.getState().getRoutingNodes()) { if (routingNode.node().isDataNode()) { if (fromNodeId == null && routingNode.numberOfOwningShards() > 0) { fromNodeId = routingNode.nodeId(); shardToBeMoved = routingNode.get(randomInt(routingNode.size() - 1)); } else { toNodeId = routingNode.nodeId(); } if (toNodeId != null && fromNodeId != null) { break; } } } assertNotNull(fromNodeId); assertNotNull(toNodeId); assertNotNull(shardToBeMoved); logger.info( "==> going to move shard [{}] from [{}] to [{}]", shardToBeMoved, fromNodeId, toNodeId); return new MoveAllocationCommand(shardToBeMoved.shardId(), fromNodeId, toNodeId); }
@Test public void testIterationMarkCharFilter() throws IOException { AnalysisService analysisService = createAnalysisService(); // test only kanji CharFilterFactory charFilterFactory = analysisService.charFilter("kuromoji_im_only_kanji"); assertNotNull(charFilterFactory); assertThat(charFilterFactory, instanceOf(KuromojiIterationMarkCharFilterFactory.class)); String source = "ところゞゝゝ、ジヾが、時々、馬鹿々々しい"; String expected = "ところゞゝゝ、ジヾが、時時、馬鹿馬鹿しい"; assertCharFilterEquals(charFilterFactory.create(new StringReader(source)), expected); // test only kana charFilterFactory = analysisService.charFilter("kuromoji_im_only_kana"); assertNotNull(charFilterFactory); assertThat(charFilterFactory, instanceOf(KuromojiIterationMarkCharFilterFactory.class)); expected = "ところどころ、ジジが、時々、馬鹿々々しい"; assertCharFilterEquals(charFilterFactory.create(new StringReader(source)), expected); // test default charFilterFactory = analysisService.charFilter("kuromoji_im_default"); assertNotNull(charFilterFactory); assertThat(charFilterFactory, instanceOf(KuromojiIterationMarkCharFilterFactory.class)); expected = "ところどころ、ジジが、時時、馬鹿馬鹿しい"; assertCharFilterEquals(charFilterFactory.create(new StringReader(source)), expected); }
@Test public void testGetAllServices() throws Exception { getClient().createService(serv); ServiceList serviceList = getClient().getAllServices(); assertNotNull(serviceList); assertNotNull(serviceList.getItems()); assertThat(serviceList.getItems().size(), greaterThan(0)); }
@Test public void testGetSelectedPodsWithEmptyLabel() throws Exception { PodList selectedPods = getClient().getSelectedPods(Collections.<String, String>emptyMap()); PodList allPods = getClient().getAllPods(); assertNotNull(selectedPods); assertNotNull(selectedPods.getItems()); assertEquals(allPods.getItems().size(), selectedPods.getItems().size()); }
@Test public void testGetSelectedPods() throws Exception { getClient().createPod(pod); PodList selectedPods = getClient().getSelectedPods(pod.getLabels()); assertNotNull(selectedPods); assertNotNull(selectedPods.getItems()); assertEquals(1, selectedPods.getItems().size()); }
@Test public void testSPR_9051() throws Exception { assertNotNull(enigma); assertNotNull(lifecycleBean); assertTrue(lifecycleBean.isInitialized()); Set<String> names = new HashSet<String>(); names.add(enigma.toString()); names.add(lifecycleBean.getName()); assertEquals(names, new HashSet<String>(Arrays.asList("enigma #1", "enigma #2"))); }
@Test public void testUpdateReplicationControllerToZero() throws Exception { getClient().createReplicationController(contr); getClient().updateReplicationController(contr.getId(), 0); Thread.sleep(10000); PodList podList = getClient().getSelectedPods(contr.getLabels()); assertNotNull(podList); assertNotNull(podList.getItems()); assertEquals(0, podList.getItems().size()); }
@Test public void testTask() { assertTrue(getTask().isEnabled()); assertEquals(TEST_TASK_NAME, getTask().getName()); assertNull(getTask().getDescription()); assertSame(project, getTask().getProject()); assertEquals(getExpectedStandardOutputCapture(), getTask().getStandardOutputCapture()); assertEquals(new HashMap(), getTask().getAdditionalProperties()); assertNotNull(getTask().getInputs()); assertNotNull(getTask().getOutputs()); assertNotNull(getTask().getOnlyIf()); assertTrue(getTask().getOnlyIf().isSatisfiedBy(getTask())); }
@Test public void testReturnResource() { GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxTotal(1); poolConfig.setMaxWaitMillis(1); pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig); pool.setClientResources(LettuceTestClientResources.getSharedClientResources()); pool.afterPropertiesSet(); RedisAsyncConnection<byte[], byte[]> client = pool.getResource(); assertNotNull(client); pool.returnResource(client); assertNotNull(pool.getResource()); client.close(); }
@Test public void testCreatePod() throws Exception { log.info("Testing Pods ...."); if (log.isDebugEnabled()) { log.debug("Creating a Pod " + pod); } Pod createPod = getClient().createPod(pod); assertEquals(pod.getId(), createPod.getId()); assertNotNull(getClient().getPod(pod.getId())); assertEquals("Waiting", createPod.getCurrentState().getStatus()); ExecutorService executor = Executors.newSingleThreadExecutor(); Future<Pod> future = executor.submit( new Callable<Pod>() { public Pod call() throws Exception { Pod newPod; do { log.info("Waiting for Pod to be ready: " + pod.getId()); Thread.sleep(1000); newPod = getClient().getPod(pod.getId()); StateInfo info = newPod.getCurrentState().getInfo("master"); if (info.getState("waiting") != null) { throw new RuntimeException("Pod is waiting due to " + info.getState("waiting")); } } while (!"Running".equals(newPod.getCurrentState().getStatus())); return newPod; } }); try { createPod = future.get(90, TimeUnit.SECONDS); } finally { executor.shutdownNow(); } assertNotNull(createPod.getCurrentState().getInfo("master").getState("running")); assertNotNull(createPod.getCurrentState().getNetInfo().getState("running")); // test recreation from same id try { getClient().createPod(pod); fail("Should have thrown exception"); } catch (Exception e) { // ignore } assertNotNull(getClient().getPod(pod.getId())); }
@Test(expected = RepositoryException.class) public void testGetWorkflowsNullRepository() throws RepositoryException { DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null); List flows = repo.getWorkflows(); assertNotNull(flows); }
@Test public void testSvValues() throws IOException { int numDocs = 1000000; int numOrdinals = numDocs / 4; Map<Integer, Long> controlDocToOrdinal = new HashMap<>(); OrdinalsBuilder builder = new OrdinalsBuilder(numDocs); long ordinal = builder.currentOrdinal(); for (int doc = 0; doc < numDocs; doc++) { if (doc % numOrdinals == 0) { ordinal = builder.nextOrdinal(); } controlDocToOrdinal.put(doc, ordinal); builder.addDoc(doc); } Ordinals ords = builder.build(ImmutableSettings.EMPTY); assertThat(ords, instanceOf(SinglePackedOrdinals.class)); RandomAccessOrds docs = ords.ordinals(); final SortedDocValues singleOrds = DocValues.unwrapSingleton(docs); assertNotNull(singleOrds); for (Map.Entry<Integer, Long> entry : controlDocToOrdinal.entrySet()) { assertThat(entry.getValue(), equalTo((long) singleOrds.getOrd(entry.getKey()))); } }
/** @since OODT-205 */ @Test public void testWorkflowConditions() { DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds); Workflow w = null; try { w = repo.getWorkflowById("1"); } catch (Exception e) { fail(e.getMessage()); } assertNotNull(w); assertNotNull(w.getConditions()); assertTrue(w.getConditions().size() > 0); assertEquals(w.getConditions().size(), 1); }
public PaymentWS createPaymentWS(Integer userId, Date date, String note) throws Exception { JbillingAPI api = JbillingAPIFactory.getAPI(); PaymentWS payment = new PaymentWS(); payment.setAmount(new BigDecimal("15.00")); payment.setIsRefund(new Integer(0)); payment.setMethodId(Constants.PAYMENT_METHOD_CHEQUE); payment.setPaymentDate(date); payment.setCreateDatetime(date); payment.setResultId(Constants.RESULT_ENTERED); payment.setCurrencyId(new Integer(1)); payment.setUserId(userId); payment.setPaymentNotes(note); payment.setPaymentPeriod(new Integer(1)); PaymentInformationWS cheque = com.sapienter.jbilling.server.user.WSTest.createCheque("ws bank", "2232-2323-2323", date); payment.getPaymentInstruments().add(cheque); System.out.println("Applying payment"); Integer ret = api.applyPayment(payment, new Integer(35)); System.out.println("Created payemnt " + ret); assertNotNull("Didn't get the payment id", ret); payment.setId(ret); return payment; }
@Test public void testGetWorkflowInstancesByStatus() throws Exception { List<WorkflowInstance> wflows = fmc.getWorkflowInstancesByStatus("QUEUED"); assertNotNull(wflows); }
@Test @Ignore public void shouldFindAllByIdQuery() { // todo : find solution for findAll(Iterable<Ids> ids) // given String documentId = randomNumeric(5); SampleEntity sampleEntity = new SampleEntity(); sampleEntity.setId(documentId); sampleEntity.setMessage("hello world."); sampleEntity.setVersion(System.currentTimeMillis()); repository.save(sampleEntity); String documentId2 = randomNumeric(5); SampleEntity sampleEntity2 = new SampleEntity(); sampleEntity2.setId(documentId2); sampleEntity2.setMessage("hello world."); sampleEntity2.setVersion(System.currentTimeMillis()); repository.save(sampleEntity2); // when Iterable<SampleEntity> sampleEntities = repository.findAll(Arrays.asList(documentId, documentId2)); // then assertNotNull("sample entities cant be null..", sampleEntities); }
@Test @SuppressWarnings("unchecked") public void getComponentSubscriptionByAnAuthenticatedUser() throws Exception { WebResource resource = resource(); UserDetailWithProfiles user = new UserDetailWithProfiles(); user.setFirstName("Bart"); user.setLastName("Simpson"); user.setId("10"); user.addProfile(COMPONENT_ID, SilverpeasRole.writer); user.addProfile(COMPONENT_ID, SilverpeasRole.user); String sessionKey = authenticate(user); SubscriptionService mockedSubscriptionService = mock(SubscriptionService.class); ComponentSubscription subscription = new ComponentSubscription("10", COMPONENT_ID); Collection<ComponentSubscription> subscriptions = Lists.newArrayList(subscription); when((Collection<ComponentSubscription>) mockedSubscriptionService.getUserSubscriptionsByComponent("10", COMPONENT_ID)) .thenReturn(subscriptions); getTestResources() .getMockableSubscriptionService() .setImplementation(mockedSubscriptionService); SubscriptionEntity[] entities = resource .path(SUBSCRIPTION_RESOURCE_PATH) .header(HTTP_SESSIONKEY, sessionKey) .accept(MediaType.APPLICATION_JSON) .get(SubscriptionEntity[].class); assertNotNull(entities); assertThat(entities.length, is(1)); assertThat(entities[0], SubscriptionEntityMatcher.matches((Subscription) subscription)); }
@Test public void testCollectDocId() throws Exception { setUpCharacters(); Planner.Context plannerContext = new Planner.Context(clusterService(), UUID.randomUUID()); CollectPhase collectNode = createCollectNode(plannerContext, false); List<Bucket> results = getBuckets(collectNode); assertThat(results.size(), is(2)); int seenJobSearchContextId = -1; for (Bucket rows : results) { assertThat(rows.size(), is(1)); Object docIdCol = rows.iterator().next().get(0); assertNotNull(docIdCol); assertThat(docIdCol, instanceOf(Long.class)); long docId = (long) docIdCol; // unpack jobSearchContextId and reader doc id from docId int jobSearchContextId = (int) (docId >> 32); int doc = (int) docId; assertThat(doc, is(0)); assertThat(jobSearchContextId, greaterThan(-1)); if (seenJobSearchContextId == -1) { assertThat(jobSearchContextId, anyOf(is(0), is(1))); seenJobSearchContextId = jobSearchContextId; } else { assertThat(jobSearchContextId, is(seenJobSearchContextId == 0 ? 1 : 0)); } } }
@Test @SuppressWarnings("unchecked") public void testDoWithRetry_ReadTimeOut() throws Exception { AmazonElasticMapReduceCustomClient client = new AmazonElasticMapReduceCustomClient("dummy", "dummy"); client.setRequestInterval(100); Callable callable = mock(Callable.class); AmazonClientException exception = new AmazonClientException("Unable to execute HTTP request: Read timed out"); when(callable.call()).thenThrow(exception, exception, exception).thenReturn(new Object()); long startTime = System.currentTimeMillis(); Object result = client.doThrottleSafe(callable); assertNotNull(result); assertThat( (System.currentTimeMillis() - startTime), greaterThanOrEqualTo(3 * client.getRequestInterval())); // now exceed retries client.setMaxRetriesOnConnectionErrors(2); when(callable.call()).thenThrow(exception, exception, exception).thenReturn(new Object()); try { client.doThrottleSafe(callable); fail("should throw exception"); } catch (Exception e) { assertSame(exception, e); } }
@Test @SuppressWarnings("unchecked") public void getComponentSubscribersByAnAuthenticatedUser() throws Exception { WebResource resource = resource(); UserDetailWithProfiles user = new UserDetailWithProfiles(); user.setFirstName("Bart"); user.setLastName("Simpson"); user.setId("10"); user.addProfile(COMPONENT_ID, SilverpeasRole.writer); user.addProfile(COMPONENT_ID, SilverpeasRole.user); String sessionKey = authenticate(user); SubscriptionService mockedSubscriptionService = mock(SubscriptionService.class); List<String> subscribers = Lists.newArrayList("5", "6", "7", "20"); when(mockedSubscriptionService.getSubscribers(new ForeignPK("0", COMPONENT_ID))) .thenReturn(subscribers); getTestResources() .getMockableSubscriptionService() .setImplementation(mockedSubscriptionService); String[] entities = resource .path(SUBSCRIPTION_RESOURCE_PATH + "/subscribers/0") .header(HTTP_SESSIONKEY, sessionKey) .accept(MediaType.APPLICATION_JSON) .get(String[].class); assertNotNull(entities); assertThat(entities.length, is(4)); assertThat(entities, is(new String[] {"5", "6", "7", "20"})); }
@Test public void savingEmptyCollectionIsNoOp() throws Exception { List<User> result = userDao.save(new ArrayList<User>()); assertNotNull(result); assertTrue(result.isEmpty()); }
@Test public void savingNullCollectionIsNoOp() throws Exception { List<User> result = userDao.save((Collection<User>) null); assertNotNull(result); assertTrue(result.isEmpty()); }
@Test public void testGetWorkflowInstances() throws IOException, XmlRpcException { List<WorkflowInstance> wfinstances = fmc.getWorkflowInstances(); assertNotNull(wfinstances); }
/* DATAES-82 */ @Test public void shouldFindAllByIdQuery() { // given String documentId = randomNumeric(5); SampleEntity sampleEntity = new SampleEntity(); sampleEntity.setId(documentId); sampleEntity.setMessage("hello world."); sampleEntity.setVersion(System.currentTimeMillis()); repository.save(sampleEntity); String documentId2 = randomNumeric(5); SampleEntity sampleEntity2 = new SampleEntity(); sampleEntity2.setId(documentId2); sampleEntity2.setMessage("hello world."); sampleEntity2.setVersion(System.currentTimeMillis()); repository.save(sampleEntity2); // when Iterable<SampleEntity> sampleEntities = repository.findAll(Arrays.asList(documentId, documentId2)); // then assertNotNull("sample entities cant be null..", sampleEntities); List<SampleEntity> entities = Lists.newArrayList(sampleEntities); assertThat(entities.size(), is(2)); }
@Test public void savesCollectionCorrectly() throws Exception { List<User> result = userDao.save(Arrays.asList(firstUser, secondUser, thirdUser)); assertNotNull(result); assertThat(result.size(), is(3)); assertThat(result, hasItems(firstUser, secondUser, thirdUser)); }
/** @see DATAREDIS-462 */ @Test public void poolWorksWithoutClientResources() { pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()); pool.setDatabase(1); pool.afterPropertiesSet(); assertNotNull(pool.getResource()); }