org.assertj.core.util.Lists Java Examples
The following examples show how to use
org.assertj.core.util.Lists.
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: PermGetNodesAllowlistTest.java From besu with Apache License 2.0 | 6 votes |
@Test public void shouldReturnSuccessResponseWhenListPopulated() { final JsonRpcRequestContext request = buildRequest(); final JsonRpcResponse expected = new JsonRpcSuccessResponse( request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3)); when(nodeLocalConfigPermissioningController.getNodesAllowlist()) .thenReturn(buildNodesList(enode1, enode2, enode3)); final JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist(); verifyNoMoreInteractions(nodeLocalConfigPermissioningController); }
Example #2
Source File: ExplodedTupleValueParameterParserTest.java From vertx-web with Apache License 2.0 | 6 votes |
@Test public void testNoAdditionalItems() { ExplodedTupleValueParameterParser parser = new ExplodedTupleValueParameterParser( TestParsers.SAMPLE_TUPLE_ITEMS_PARSERS, null, "bla" ); Map<String, List<String>> map = new HashMap<>(); map.put("bla", Lists.newArrayList("1", "hello", "2", "true")); map.put("other", Collections.singletonList("aaa")); Object result = parser.parseParameter(map); assertThat(result) .isInstanceOfSatisfying(JsonArray.class, ja -> assertThat(ja) .isEqualTo(TestParsers.SAMPLE_TUPLE.copy().add("true")) ); assertThat(map) .containsKey("other") .doesNotContainKey("bla"); }
Example #3
Source File: VetControllerTests.java From spring-graalvm-native with Apache License 2.0 | 6 votes |
@BeforeEach void setup() { Vet james = new Vet(); james.setFirstName("James"); james.setLastName("Carter"); james.setId(1); Vet helen = new Vet(); helen.setFirstName("Helen"); helen.setLastName("Leary"); helen.setId(2); Specialty radiology = new Specialty(); radiology.setId(1); radiology.setName("radiology"); helen.addSpecialty(radiology); given(this.vets.findAll()).willReturn(Lists.newArrayList(james, helen)); }
Example #4
Source File: EurekaVipAddressRoundRobinWithAzAffinityServiceTest.java From riposte with Apache License 2.0 | 6 votes |
@Test public void roundRobinsDoesNotTriggerNPEWhenNoAvailabilityZoneIsPresentInTheMetadata() { // given InstanceInfo iiMock = mock(InstanceInfo.class); doReturn(new HashMap<>()).when(iiMock).getMetadata(); doReturn(InstanceInfo.InstanceStatus.UP).when(iiMock).getStatus(); List<InstanceInfo> expectedInstances = Lists.newArrayList(iiMock); doReturn(expectedInstances).when(serviceSpy).getActiveInstanceInfosForVipAddressBlocking(vip); // when Optional<InstanceInfo> result = serviceSpy.getActiveInstanceInfoForVipAddressBlocking(vip); // then assertThat(result).isNotEmpty(); assertThat(result.get()).isEqualTo(expectedInstances.get(0)); }
Example #5
Source File: ResourceTaggingManagerTest.java From pacbot with Apache License 2.0 | 6 votes |
/** * Tag resource 2. * * @throws Exception the exception */ @Test public void tagResource2() throws Exception{ PowerMockito.mockStatic(CommonUtils.class); Map<String, Object> clientMap = Maps.newHashMap(); clientMap.put("client", s3Mock); clientMap.put("field234", "field234"); clientMap.put("field345", "field345"); Map<String, String> pacTag = Maps.newHashMap(); clientMap.put("field123", "field123"); clientMap.put("field234", "field234"); clientMap.put("field345", "field345"); List<TagSet> existingTargets = Lists.newArrayList(); TagSet tagSet = new TagSet(); tagSet.setTag("test", "value2"); existingTargets.add(tagSet); existingTargets.add(tagSet); PowerMockito.when(bucketTaggingConfiguration.getAllTagSets()).thenReturn(existingTargets); PowerMockito.when(s3Mock.getBucketTaggingConfiguration(anyString())).thenReturn(bucketTaggingConfiguration); PowerMockito.when(CommonUtils.getPropValue(anyString())).thenReturn("test"); final ResourceTaggingManager classUnderTest = PowerMockito.spy(new ResourceTaggingManager()); assertTrue(classUnderTest.tagResource("resourceId", clientMap, AWSService.S3, pacTag)); }
Example #6
Source File: ContactControllerTest.java From http-patch-spring with MIT License | 6 votes |
@Test @SneakyThrows public void findContacts_shouldReturn200_whenThereAreContacts() { when(service.findContacts()).thenReturn(Lists.list(contactPersisted())); mockMvc.perform(get("/contacts") .accept(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$", hasSize(1))) .andExpect(jsonPath("$.[0].*", hasSize(4))) .andExpect(jsonPath("$.[0].id").value(1)) .andExpect(jsonPath("$.[0].name").value("John Appleseed")) .andExpect(jsonPath("$.[0].createdDateTime").value("2019-01-01T00:00:00Z")) .andExpect(jsonPath("$.[0].lastModifiedDateTime").value("2019-01-01T00:00:00Z")); verify(service).findContacts(); verifyNoMoreInteractions(service); verifyZeroInteractions(patchHelper); verify(mapper).asOutput(anyList()); }
Example #7
Source File: CsvImportTest.java From kid-bank with Apache License 2.0 | 6 votes |
@Test public void multipleDepositRowsShouldResultInMultipleDepositTransactions() throws Exception { List<String> csvList = Lists.list( "05/03/2018,Cash Deposit, $6.75 ,Bottle return", "05/24/2018,Deposit, $7.75 ,Bottle return"); List<Transaction> transactions = new CsvImporter().importFrom(csvList); assertThat(transactions) .usingElementComparatorIgnoringFields("id") .containsExactly( CsvImporter.createDeposit(LocalDateTime.of(2018, 5, 3, 0, 0), 675, "Bottle return"), CsvImporter.createDeposit(LocalDateTime.of(2018, 5, 24, 0, 0), 775, "Bottle return")); }
Example #8
Source File: JettyFactory.java From java-tutorial with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
public static void supportJspAndSetTldJarNames(Server server, String... jarNames) { WebAppContext context = (WebAppContext) server.getHandler(); // This webapp will use jsps and jstl. We need to enable the // AnnotationConfiguration in // order to correctly set up the jsp container org.eclipse.jetty.webapp.Configuration.ClassList classlist = org.eclipse.jetty.webapp.Configuration.ClassList .setServerDefault(server); classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration"); // Set the ContainerIncludeJarPattern so that jetty examines these container-path // jars for // tlds, web-fragments etc. // If you omit the jar that contains the jstl .tlds, the jsp engine will scan for // them // instead. ArrayList jarNameExprssions = Lists.newArrayList(".*/[^/]*servlet-api-[^/]*\\.jar$", ".*/javax.servlet.jsp.jstl-.*\\.jar$", ".*/[^/]*taglibs.*\\.jar$"); for (String jarName : jarNames) { jarNameExprssions.add(".*/" + jarName + "-[^/]*\\.jar$"); } context.setAttribute("org.eclipse.jetty.io.github.dunwu.javaee.server.webapp.ContainerIncludeJarPattern", StringUtils.join(jarNameExprssions, '|')); }
Example #9
Source File: CliqueMiningCoordinatorTest.java From besu with Apache License 2.0 | 6 votes |
@Test public void locallyGeneratedBlockInvalidatesMiningEvenIfInTurn() { // Note also - validators is an hard-ordered LIST, thus in-turn will follow said list - block_1 // should be created by Proposer, and thus will be in-turn. final CliqueMiningCoordinator coordinator = new CliqueMiningCoordinator(blockChain, minerExecutor, syncState, miningTracker); coordinator.enable(); coordinator.start(); verify(minerExecutor, times(1)).startAsyncMining(any(), any(), any()); reset(minerExecutor); when(minerExecutor.startAsyncMining(any(), any(), any())).thenReturn(Optional.of(blockMiner)); final Block importedBlock = createEmptyBlock(1, blockChain.getChainHeadHash(), proposerKeys); blockChain.appendBlock(importedBlock, Lists.emptyList()); // The minerExecutor should not be invoked as the mining operation was conducted by an in-turn // validator, and the created block came from an out-turn validator. ArgumentCaptor<BlockHeader> varArgs = ArgumentCaptor.forClass(BlockHeader.class); verify(minerExecutor, times(1)).startAsyncMining(any(), any(), varArgs.capture()); assertThat(varArgs.getValue()).isEqualTo(blockChain.getChainHeadHeader()); }
Example #10
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void getAcknowledgementReturnsExpected() { final Acknowledgement timeoutAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.REQUEST_TIMEOUT, KNOWN_DITTO_HEADERS, null); final AcknowledgementLabel customAckLabel = AcknowledgementLabel.of("foo"); final Acknowledgement customAcknowledgement = ImmutableAcknowledgement.of(customAckLabel, KNOWN_ENTITY_ID, HttpStatusCode.OK, KNOWN_DITTO_HEADERS, null); final List<Acknowledgement> acknowledgements = Lists.list(KNOWN_ACK_1, timeoutAcknowledgement, customAcknowledgement); final ImmutableAcknowledgements underTest = ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS); assertThat(underTest.getAcknowledgement(DittoAcknowledgementLabel.TWIN_PERSISTED)) .contains(timeoutAcknowledgement); assertThat(underTest.getAcknowledgement(customAckLabel)).contains(customAcknowledgement); }
Example #11
Source File: KmsPolicyServiceTest.java From cerberus with Apache License 2.0 | 6 votes |
@Test public void test_that_removePolicyFromStatement_removes_the_given_statement() { String removeId = "remove id"; String keepId = "keep id"; Statement statementToRemove = new Statement(Statement.Effect.Allow) .withId(removeId) .withActions(KMSActions.AllKMSActions); Statement statementToKeep = new Statement(Statement.Effect.Deny).withId(keepId).withActions(KMSActions.AllKMSActions); Policy policy = new Policy("policy", Lists.newArrayList(statementToKeep, statementToRemove)); kmsPolicyService.removeStatementFromPolicy(policy, removeId); assertTrue(policy.getStatements().contains(statementToKeep)); assertFalse(policy.getStatements().contains(statementToRemove)); }
Example #12
Source File: FxRateCalculatorImplTest.java From objectlabkit with Apache License 2.0 | 6 votes |
@Test public void testNoPossibleCross() { FxRateCalculatorBuilder builder = new FxRateCalculatorBuilder() // .addRateSnapshot( new FxRateImpl(CurrencyPair.of("EUR", "USD"), null, true, BigDecimalUtil.bd("1.6"), BigDecimalUtil.bd("1.61"), new JdkCurrencyProvider()))// .addRateSnapshot( new FxRateImpl(CurrencyPair.of("GBP", "CHF"), null, true, BigDecimalUtil.bd("2.1702"), BigDecimalUtil.bd("2.1707"), new JdkCurrencyProvider()))// .addRateSnapshot( new FxRateImpl(CurrencyPair.of("EUR", "GBP"), null, true, BigDecimalUtil.bd("0.7374"), BigDecimalUtil.bd("0.7379"), new JdkCurrencyProvider()))// .orderedCurrenciesForCross(Lists.newArrayList("USD")) // impossible to find EUR/CHF ; final FxRateCalculator calc = new FxRateCalculatorImpl(builder); CurrencyPair target = CurrencyPair.of("EUR", "CHF"); final Optional<FxRate> fx = calc.findFx(target); assertThat(fx.isPresent()).isFalse(); }
Example #13
Source File: RuntimeServiceFluentMockTest.java From camunda-bpm-mockito with Apache License 2.0 | 6 votes |
@Test public void testSetVariableLocalBehavior() { // given new RuntimeServiceFluentMock(runtimeService) .getVariableLocal("Foo", "Bar") .getVariableLocal("Bar", "Zee", "Tree") .getVariablesLocal(Variables.createVariables().putValue("Kermit", "TheFrog")) .getVariablesLocal(Lists.newArrayList("Piggy"), Variables.createVariables().putValue("Piggy", "ThePig")); // when -> then // single assertThat(runtimeService.getVariableLocal(task.getExecutionId(), "Foo")).isEqualTo("Bar"); // multiple assertThat(runtimeService.getVariableLocal(task.getExecutionId(), "Bar")).isEqualTo("Zee"); assertThat(runtimeService.getVariableLocal(task.getExecutionId(), "Bar")).isEqualTo("Tree"); // all assertThat(runtimeService.getVariablesLocal(task.getExecutionId())) .isEqualTo(Variables.createVariables().putValue("Kermit", "TheFrog")); // some assertThat(runtimeService.getVariablesLocal(task.getExecutionId(), Lists.newArrayList("Piggy"))) .isEqualTo(Variables.createVariables().putValue("Piggy", "ThePig")); }
Example #14
Source File: ProtocolVersionSupportTest.java From simulacron with Apache License 2.0 | 6 votes |
@Test public void shouldInheritClusterOverride() { BoundCluster cluster = new BoundCluster( ClusterSpec.builder().withPeerInfo("protocol_versions", Lists.newArrayList(5)).build(), 0L, null); BoundDataCenter dc = new BoundDataCenter(cluster); BoundNode node = new BoundNode( new LocalAddress(UUID.randomUUID().toString()), NodeSpec.builder().withName("node0").withId(0L).build(), Collections.emptyMap(), cluster, dc, null, timer, null, // channel reference only needed for closing, not useful in context of this test. false); assertThat(node.getFrameCodec().getSupportedProtocolVersions()).containsOnly(5); assertThat(dc.getFrameCodec().getSupportedProtocolVersions()).containsOnly(5); assertThat(cluster.getFrameCodec().getSupportedProtocolVersions()).containsOnly(5); }
Example #15
Source File: TaskArchiveController.java From PoseidonX with Apache License 2.0 | 6 votes |
@ResponseBody @RequestMapping(value = "/getArchiveVersionByArchiveId", method = RequestMethod.POST) public List<TaskArchiveVersionDTO> getTaskVersionByArchiveId(String archiveId) { if(StringUtils.isBlank(archiveId)){ return Lists.newArrayList(); } List<TaskArchiveVersionPO> taskArchiveVersionPOs =taskArchiveService.getTaskArchiveVersionByArchiveId(Integer.valueOf(archiveId)); List<TaskArchiveVersionDTO> taskArchiveVersionDTOs = new ArrayList<TaskArchiveVersionDTO>(); for(TaskArchiveVersionPO taskArchiveVersionPO : taskArchiveVersionPOs){ TaskArchiveVersionDTO taskArchiveVersionDTO = new TaskArchiveVersionDTO(); taskArchiveVersionDTO.setId(taskArchiveVersionPO.getId()); String url = taskArchiveVersionPO.getTaskArchiveVersionUrl().replace(StreamContant.HDFS_PROJECT_PACKAGE_ROOT,""); url = url + " " + (StringUtils.isBlank(taskArchiveVersionPO.getTaskArchiveVersionRemark())?"": "[" +taskArchiveVersionPO.getTaskArchiveVersionRemark()+ "]"); taskArchiveVersionDTO.setTaskArchiveVersionUrl(url); taskArchiveVersionDTO.setTaskArchiveVersionRemark(taskArchiveVersionPO.getTaskArchiveVersionRemark()); taskArchiveVersionDTO.setCreateUser(taskArchiveVersionPO.getCreateUser()); taskArchiveVersionDTO.setCreateTime(taskArchiveVersionPO.getCreateTime()); taskArchiveVersionDTOs.add(taskArchiveVersionDTO); } return taskArchiveVersionDTOs; }
Example #16
Source File: EditDistanceBenchmark.java From termsuite-core with Apache License 2.0 | 6 votes |
public int doDistance(EditDistance dist, String distName) { Stopwatch sw = Stopwatch.createStarted(); int cnt = 0; List<Double> distances = Lists.newArrayList(); String t1, t2; for(int i=0;i<terms.size();i++) { t1 = terms.get(i); for(int j=i+1;j<terms.size();j++) { t2 = terms.get(j); cnt++; distances.add(dist.computeNormalized(t1, t2, 0.9)); } } sw.stop(); System.out.format("%s finished. %d distances computed in %s (%.2f per seconds)%n", distName, cnt, sw, 1000000*((float)cnt/sw.elapsed(TimeUnit.MICROSECONDS))); return cnt; }
Example #17
Source File: PreparedCertificateTest.java From besu with Apache License 2.0 | 6 votes |
@Test public void roundTripRlpWithPreparePayload() { final SignedData<ProposalPayload> signedProposalPayload = signedProposal(); final PreparePayload preparePayload = new PreparePayload(ROUND_IDENTIFIER, Hash.fromHexStringLenient("0x8523ba6e7c5f59ae87")); final Signature signature = Signature.create(BigInteger.ONE, BigInteger.TEN, (byte) 0); final SignedData<PreparePayload> signedPrepare = SignedData.from(preparePayload, signature); final PreparedCertificate preparedCert = new PreparedCertificate(signedProposalPayload, Lists.newArrayList(signedPrepare)); final BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); preparedCert.writeTo(rlpOut); final RLPInput rlpInput = RLP.input(rlpOut.encoded()); PreparedCertificate actualPreparedCert = PreparedCertificate.readFrom(rlpInput); assertThat(actualPreparedCert.getPreparePayloads()) .isEqualTo(preparedCert.getPreparePayloads()); assertThat(actualPreparedCert.getProposalPayload()) .isEqualTo(preparedCert.getProposalPayload()); }
Example #18
Source File: FilterRepositoryTest.java From besu with Apache License 2.0 | 6 votes |
@Test public void getFilterCollectionShouldReturnAllFiltersOfSpecificType() { final BlockFilter blockFilter1 = new BlockFilter("foo"); final BlockFilter blockFilter2 = new BlockFilter("biz"); final PendingTransactionFilter pendingTxFilter1 = new PendingTransactionFilter("bar"); final Collection<BlockFilter> expectedFilters = Lists.newArrayList(blockFilter1, blockFilter2); repository.save(blockFilter1); repository.save(blockFilter2); repository.save(pendingTxFilter1); final Collection<BlockFilter> blockFilters = repository.getFiltersOfType(BlockFilter.class); assertThat(blockFilters).containsExactlyInAnyOrderElementsOf(expectedFilters); }
Example #19
Source File: TermAssert.java From termsuite-core with Apache License 2.0 | 6 votes |
public TermAssert hasCompositionLemmas(String... lemmas) { isNotNull(); isCompound(); Word word = actual.getWords().get(0).getWord(); List<String> expectedComps = Lists.newArrayList(lemmas); List<String> actualComps = word.getComponents().stream() .map(Component::getLemma) .collect(Collectors.toList()); if(word.getComponents().size() != lemmas.length) { failWithMessage("Expected <%s> components for term %s, but got <%s> components: %s", lemmas.length, actual, word.getComponents().size(), actualComps); } else { if(!expectedComps.equals(actualComps)) failWithMessage("Expected composition <%s> for term %s, but got composition <%s>", expectedComps, actual, actualComps); } return this; }
Example #20
Source File: HeimdallDecorationFilterTest.java From heimdall with Apache License 2.0 | 5 votes |
@Test public void routeWithoutApiBasePath() { this.request.setRequestURI("/v2/api/foo/1"); this.request.setMethod(HttpMethod.GET.name()); Map<String, ZuulRoute> routes = new LinkedHashMap<>(); ZuulRoute route = new ZuulRoute("idFoo", "/v2/api/foo/{id}", null, "my.dns.com.br", true, null, Collections.newSetFromMap(new ConcurrentHashMap<>())); routes.put("/v2/api/foo/{id}", route); EnvironmentInfo environmentInfo = new EnvironmentInfo(); environmentInfo.setId(1L); environmentInfo.setOutboundURL("http://outbound:8080"); environmentInfo.setVariables(new HashMap<>()); Credential opPost = new Credential(HttpMethod.POST.name(), "/api/foo", "/v2", "apiName", 10L, 88L, 10L, false); Credential opGet = new Credential(HttpMethod.GET.name(), "/api/foo/{id}", "/v2", "apiName", 10L, 88L, 10L, false); Credential opDelete = new Credential(HttpMethod.DELETE.name(), "/api/foo/{id}", "/v2", "apiName", 10L, 88L, 10L, false); Mockito.when(routeLocator.getAtomicRoutes()).thenReturn(new AtomicReference<>(routes)); Mockito.when(credentialRepository.findByPattern("/v2/api/foo/{id}")).thenReturn(Lists.newArrayList(opPost, opGet, opDelete)); Mockito.when(environmentInfoRepository.findByApiIdAndEnvironmentInboundURL(10L, "http://localhost/v2/api/foo/1")).thenReturn(environmentInfo); this.filter.run(); assertEquals("/api/foo/1", this.ctx.get(REQUEST_URI_KEY)); assertTrue(this.ctx.sendZuulResponse()); }
Example #21
Source File: LeaseAmendmentItem.java From estatio with Apache License 2.0 | 5 votes |
@Programmatic public static List<LeaseItemType> applicableToFromString(final String applicableToString){ if (applicableToString==null || applicableToString.isEmpty()) return Lists.emptyList(); List<LeaseItemType> result = new ArrayList<>(); final String[] strings = applicableToString.split(","); for (String s : strings){ result.add(LeaseItemType.valueOf(s)); } return result; }
Example #22
Source File: GatewayHttpConfigTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void tryToGetInstanceWithUnknownQueryParametersAsHeaders() { final List<String> unknownHeaderKeys = Lists.newArrayList("foo", "bar"); final List<String> knownHeaderKeys = Lists.newArrayList(DittoHeaderDefinition.CORRELATION_ID.getKey(), DittoHeaderDefinition.RESPONSE_REQUIRED.getKey()); final List<String> allHeaderKeys = new ArrayList<>(knownHeaderKeys); allHeaderKeys.addAll(unknownHeaderKeys); final String configPath = "http." + HttpConfig.GatewayHttpConfigValue.QUERY_PARAMS_AS_HEADERS.getConfigPath(); final Config config = ConfigFactory.parseMap(Maps.newHashMap(configPath, allHeaderKeys)); assertThatExceptionOfType(DittoConfigError.class) .isThrownBy(() -> GatewayHttpConfig.of(config)) .withMessage("The query parameter names <%s> do not denote known header keys!", unknownHeaderKeys) .withNoCause(); }
Example #23
Source File: ProjectRepositorySortIT.java From spring-data-cosmosdb with MIT License | 5 votes |
@Test public void testFindAllSortASC() { final Sort sort = Sort.by(Sort.Direction.ASC, "starCount"); final List<SortedProject> projects = Lists.newArrayList(this.repository.findAll(sort)); PROJECTS.sort(Comparator.comparing(SortedProject::getStarCount)); Assert.assertEquals(PROJECTS.size(), projects.size()); Assert.assertEquals(PROJECTS, projects); }
Example #24
Source File: UserServiceTest.java From spring-boot-demo with MIT License | 5 votes |
/** * 测试Mybatis-Plus 批量新增 */ @Test public void testSaveList() { List<User> userList = Lists.newArrayList(); for (int i = 4; i < 14; i++) { String salt = IdUtil.fastSimpleUUID(); User user = User.builder().name("testSave" + i).password(SecureUtil.md5("123456" + salt)).salt(salt).email("testSave" + i + "@xkcoding.com").phoneNumber("1730000000" + i).status(1).lastLoginTime(new DateTime()).build(); userList.add(user); } boolean batch = userService.saveBatch(userList); Assert.assertTrue(batch); List<Long> ids = userList.stream().map(User::getId).collect(Collectors.toList()); log.debug("【userList#ids】= {}", ids); }
Example #25
Source File: OrganisationUnitHandlerShould.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); String programUid = "test_program_uid"; pathTransformer = new OrganisationUnitDisplayPathTransformer(); organisationUnitHandler = new OrganisationUnitHandlerImpl( organisationUnitStore, userOrganisationUnitLinkHandler, organisationUnitProgramLinkHandler, dataSetDataSetOrganisationUnitLinkHandler, organisationUnitGroupHandler, organisationUnitGroupLinkHandler); when(user.uid()).thenReturn("test_user_uid"); when(program.uid()).thenReturn(programUid); when(organisationUnitGroup.uid()).thenReturn("test_organisation_unit_group_uid"); List<OrganisationUnitGroup> organisationUnitGroups = Lists.newArrayList(organisationUnitGroup); OrganisationUnit.Builder builder = OrganisationUnit.builder() .uid("test_organisation_unit_uid") .programs(Collections.singletonList(program)); organisationUnitWithoutGroups = builder .build(); OrganisationUnit organisationUnitWithGroups = builder .organisationUnitGroups(organisationUnitGroups) .build(); organisationUnits = Lists.newArrayList(organisationUnitWithGroups); }
Example #26
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void getFailedAcknowledgementsReturnsExpected() { final Acknowledgement timeoutAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.REQUEST_TIMEOUT, KNOWN_DITTO_HEADERS, null); final Acknowledgement failedAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.NOT_FOUND, KNOWN_DITTO_HEADERS, null); final List<Acknowledgement> acknowledgements = Lists.list(KNOWN_ACK_1, timeoutAcknowledgement, failedAcknowledgement); final ImmutableAcknowledgements underTest = ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS); assertThat(underTest.getFailedAcknowledgements()).containsOnly(timeoutAcknowledgement, failedAcknowledgement); }
Example #27
Source File: PerformanceHintsServiceShould.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void no_program_rule_vulnerable_when_one_program_under_threshold() { when(programStore.selectAll()).thenReturn(Lists.newArrayList(program1)); when(programRuleStore.selectAll()).thenReturn(Lists.newArrayList(programRule1)); assertThat(performanceHintsService.areThereProgramsWithExcessiveProgramRules()).isEqualTo(false); assertThat(performanceHintsService.getProgramsWithExcessiveProgramRules().size()).isEqualTo(0); assertThat(performanceHintsService.areThereVulnerabilities()).isEqualTo(false); }
Example #28
Source File: CsvImportTest.java From kid-bank with Apache License 2.0 | 5 votes |
@Test public void singleRowInterestCreditShouldResultInSingleInterestCreditTransaction() throws Exception { String csv = "02/01/2018,Interest Credit, $0.08 ,Interest based on 2%/year"; List<String> csvList = Lists.list(csv); List<Transaction> transactions = new CsvImporter().importFrom(csvList); assertThat(transactions) .usingElementComparatorIgnoringFields("id") .containsExactly( Transaction.createInterestCredit(LocalDateTime.of(2018, 2, 1, 0, 0), 8)); }
Example #29
Source File: UserServiceTest.java From spring-boot-demo with MIT License | 5 votes |
@Test public void saveUserList() { List<User> users = Lists.newArrayList(); for (int i = 5; i < 15; i++) { String salt = IdUtil.fastSimpleUUID(); User user = User.builder().name("testSave" + i).password(SecureUtil.md5("123456" + salt)).salt(salt).email("testSave" + i + "@xkcoding.com").phoneNumber("1730000000" + i).status(1).lastLoginTime(new DateTime()).createTime(new DateTime()).lastUpdateTime(new DateTime()).build(); users.add(user); } userService.saveUserList(users); Assert.assertTrue(userService.getUserList().size() > 2); }
Example #30
Source File: FinancialOctPeriodGeneratorShould.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void generate_periods_for_one_year() { calendar.set(2017, 9, 1); Period period = generateExpectedPeriod("2017Oct", calendar); calendar.set(2019, 1, 21); YearlyPeriodGenerator generator = YearlyPeriodGeneratorFactory.financialOct(calendar); List<Period> generatedPeriods = generator.generatePeriods(1, 0); assertThat(generatedPeriods).isEqualTo(Lists.newArrayList(period)); }