Java Code Examples for org.assertj.core.util.Lists#newArrayList()
The following examples show how to use
org.assertj.core.util.Lists#newArrayList() .
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: 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 2
Source File: JavaRefactoringTest.java From gauge-java with Apache License 2.0 | 6 votes |
public void testRefactoringWithAlias() { ArrayList<String> stringSet = Lists.newArrayList("anyString", "anyOtherString"); StepRegistry registry = mock(StepRegistry.class); StepRegistryEntry entry = mock(StepRegistryEntry.class); when(registry.get("old step")).thenReturn(entry); when(entry.getHasAlias()).thenReturn(true); when(entry.getFileName()).thenReturn("foo"); StepValue oldStepValue = new StepValue("old step", "", new ArrayList<>()); StepValue newStepValue = new StepValue("", "", new ArrayList<>()); String parameterizedStepValue = ""; RefactoringResult result = new JavaRefactoring(oldStepValue, newStepValue, new ArrayList<>(), registry, parameterizedStepValue, saveChanges).performRefactoring(); assertFalse(result.passed()); assertEquals("Refactoring for steps having aliases are not supported.", result.errorMessage()); }
Example 3
Source File: TaskResource.java From SAPNetworkMonitor with GNU General Public License v3.0 | 6 votes |
@POST @Path("/task") public RestfulReturnResult saveTask(@Session HttpSession session, com.cloudwise.sap.niping.common.vo.Task taskVO) { Optional<Task> taskOptional = taskConverter.convertTaskVO(Optional.ofNullable(taskVO)); if (taskOptional.isPresent()) { Task task = taskOptional.get(); task.setAccountId(NiPingAuthFilter.getAccountId(session)); try { log.info("user {} save task {}", task); String taskId = taskService.saveTask(task); String selectMonitorIdString = taskVO.getSelectMonitorIdString(); ArrayList<String> monitorIds = Lists.newArrayList(); if (StringUtils.isNotBlank(selectMonitorIdString)) { monitorIds = new ArrayList<String>(Arrays.asList(selectMonitorIdString.split(","))); } taskService.assignTask(monitorIds, taskId); taskService.modifyTaskRedispatcher(taskId); } catch (NiPingException e) { return new RestfulReturnResult(e, null); } } return new RestfulReturnResult(SUCCESS, null); }
Example 4
Source File: SafeDepositBoxServiceTest.java From cerberus with Apache License 2.0 | 6 votes |
@Test public void test_that_getAssociatedSafeDepositBoxes_checks_iam_role() { String iamRoleArn = "arn:aws:iam::123456789012:role/Accounting-Role"; String rootArn = "arn:aws:iam::123456789012:root"; SafeDepositBoxRecord safeDepositBoxRecord1 = new SafeDepositBoxRecord(); List<SafeDepositBoxRecord> roleArnRecords = Lists.newArrayList(safeDepositBoxRecord1); when(safeDepositBoxDao.getIamPrincipalAssociatedSafeDepositBoxes(iamRoleArn, rootArn)) .thenReturn(roleArnRecords); when(awsIamRoleArnParser.isAssumedRoleArn(iamRoleArn)).thenReturn(false); when(awsIamRoleArnParser.convertPrincipalArnToRootArn(iamRoleArn)).thenReturn(rootArn); CerberusPrincipal roleArnPrincipal = mock(CerberusPrincipal.class); doReturn(PrincipalType.IAM).when(roleArnPrincipal).getPrincipalType(); doReturn(iamRoleArn).when(roleArnPrincipal).getName(); List<SafeDepositBoxSummary> roleArnSdbSummaries = safeDepositBoxServiceSpy.getAssociatedSafeDepositBoxes(roleArnPrincipal); assertEquals(roleArnRecords.size(), roleArnSdbSummaries.size()); }
Example 5
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 6
Source File: ProjectRepositorySortIT.java From spring-data-cosmosdb with MIT License | 5 votes |
@Test public void testFindAllUnSorted() { final Sort sort = Sort.unsorted(); final List<SortedProject> projects = Lists.newArrayList(this.repository.findAll(sort)); PROJECTS.sort(Comparator.comparing(SortedProject::getId)); projects.sort(Comparator.comparing(SortedProject::getId)); Assert.assertEquals(PROJECTS.size(), projects.size()); Assert.assertEquals(PROJECTS, projects); }
Example 7
Source File: ControlFiles.java From termsuite-core with Apache License 2.0 | 5 votes |
public static List<String[]> getRows(File file, int nbColumns, String sep) { List<String[]> rows = Lists.newArrayList(); for(String line:getLines(file)) { List<String> valuesAsList = Splitter.on(sep).splitToList(line); Preconditions.checkArgument(valuesAsList.size() == nbColumns, "Bad row format for line: \"%s\". Expected %s columns, got %s", line, nbColumns, valuesAsList.size()); rows.add(valuesAsList.toArray(new String[nbColumns])); } return rows; }
Example 8
Source File: GermanWindEnergySpec.java From termsuite-core with Apache License 2.0 | 5 votes |
@Override protected List<String> getSyntacticNotMatchingRules() { return Lists.newArrayList( "S-I-NN-A", "S-I1-NPN-CN", "S-Eg-NPN-NC", "M-PI1-NAN2-N2-P", "M-I-NN-CN", "M-I2-NCN-N", "M-PI-NNCN-N-P"); }
Example 9
Source File: AspectJUtils.java From XUpdateService with Apache License 2.0 | 5 votes |
/** * 敏感字段列表(当然这里你可以更改为可配置的) */ private static List<String> getSensitiveFieldList() { List<String> sensitiveFieldList = Lists.newArrayList(); sensitiveFieldList.add("pwd"); sensitiveFieldList.add("password"); return sensitiveFieldList; }
Example 10
Source File: MetricReportContainer.java From PoseidonX with Apache License 2.0 | 5 votes |
public static List<LineReportDTO> getReports(String topology){ Map<String,LineReportDTO> lineReports = reportContainer.get(topology); if(lineReports == null){ return Lists.newArrayList(); } return Lists.newArrayList(lineReports.values()); }
Example 11
Source File: EthGetFilterChangesIntegrationTest.java From besu with Apache License 2.0 | 5 votes |
@Test public void shouldReturnHashesIfNewBlocks() { final String filterId = filterManager.installBlockFilter(); assertThatFilterExists(filterId); final JsonRpcRequestContext request = requestWithParams(String.valueOf(filterId)); // We haven't added any blocks, so the list of new blocks should be empty. JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList()); JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByField(expected); final Block block = appendBlock(transaction); // We've added one block, so there should be one new hash. expected = new JsonRpcSuccessResponse(null, Lists.newArrayList(block.getHash().toString())); actual = method.response(request); assertThat(actual).isEqualToComparingFieldByField(expected); // The queue should be flushed and return no results. expected = new JsonRpcSuccessResponse(null, Lists.emptyList()); actual = method.response(request); assertThat(actual).isEqualToComparingFieldByField(expected); filterManager.uninstallFilter(filterId); assertThatFilterDoesNotExist(filterId); }
Example 12
Source File: DailyPeriodGeneratorShould.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void generate_daily_periods() { calendar.set(2018, 2, 4); Period period1 = generateExpectedPeriod("20180304", calendar); calendar.set(2018, 2, 5); Period period2 = generateExpectedPeriod("20180305", calendar); calendar.set(2018, 2, 6); List<Period> generatedPeriods = new DailyPeriodGenerator(calendar).generatePeriods(2, 0); List<Period> expectedPeriods = Lists.newArrayList(period1, period2); assertThat(generatedPeriods).isEqualTo(expectedPeriods); }
Example 13
Source File: ConfigListBuilder.java From termsuite-core with Apache License 2.0 | 5 votes |
public List<TerminoConfig> list() { List<TerminoConfig> configs = Lists.newArrayList(); for(Integer frequencyTh:frequencyTh) for(Integer scope:scopes) configs.add(new TerminoConfig().setFrequencyTh(frequencyTh).setScope(scope)); return configs; }
Example 14
Source File: NodeDecorationBaseTest.java From GitToolBox with Apache License 2.0 | 5 votes |
private List<DecorationPartConfig> statusBeforeLocationParts() { return Lists.newArrayList( DecorationPartConfig.builder() .withType(DecorationPartType.BRANCH) .build(), DecorationPartConfig.builder() .withType(DecorationPartType.STATUS) .build(), DecorationPartConfig.builder() .withType(DecorationPartType.LOCATION) .build() ); }
Example 15
Source File: MarshalledActivationSortTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void test() throws IOException { List<Activation> as = Lists.newArrayList(); for (String text : TEST_DATA.split( "\\n" )) { ActivationEntry line = parseLine(text); Activation a = createActivation(line); as.add(a); } as.sort( ProtobufOutputMarshaller.ActivationsSorter.INSTANCE ); assertEquals( "ActivationEntry{ruleName='ExcCh', ids=[579, null, 564]}", as.get(0).toString() ); }
Example 16
Source File: SpanishWindEnergySpec.java From termsuite-core with Apache License 2.0 | 4 votes |
@Override protected List<String> getRulesNotTested() { return Lists.newArrayList( ); }
Example 17
Source File: DistributionSetTypeManagementTest.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
@Test @Description("Verifies that the quota for software module types per distribution set type is enforced as expected.") public void quotaMaxSoftwareModuleTypes() { final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType(); // create software module types final List<Long> moduleTypeIds = Lists.newArrayList(); for (int i = 0; i < quota + 1; ++i) { final SoftwareModuleTypeCreate smCreate = entityFactory.softwareModuleType().create().name("smType_" + i) .description("smType_" + i).maxAssignments(1).colour("blue").key("smType_" + i); moduleTypeIds.add(softwareModuleTypeManagement.create(smCreate).getId()); } // assign all types at once final DistributionSetType dsType1 = distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("dst1").name("dst1")); assertThatExceptionOfType(AssignmentQuotaExceededException.class).isThrownBy( () -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType1.getId(), moduleTypeIds)); assertThatExceptionOfType(AssignmentQuotaExceededException.class).isThrownBy( () -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType1.getId(), moduleTypeIds)); // assign as many mandatory modules as possible final DistributionSetType dsType2 = distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("dst2").name("dst2")); distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType2.getId(), moduleTypeIds.subList(0, quota)); assertThat(distributionSetTypeManagement.get(dsType2.getId())).isNotEmpty(); assertThat(distributionSetTypeManagement.get(dsType2.getId()).get().getMandatoryModuleTypes().size()) .isEqualTo(quota); // assign one more to trigger the quota exceeded error assertThatExceptionOfType(AssignmentQuotaExceededException.class) .isThrownBy(() -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType2.getId(), Collections.singletonList(moduleTypeIds.get(quota)))); // assign as many optional modules as possible final DistributionSetType dsType3 = distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("dst3").name("dst3")); distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3.getId(), moduleTypeIds.subList(0, quota)); assertThat(distributionSetTypeManagement.get(dsType3.getId())).isNotEmpty(); assertThat(distributionSetTypeManagement.get(dsType3.getId()).get().getOptionalModuleTypes().size()) .isEqualTo(quota); // assign one more to trigger the quota exceeded error assertThatExceptionOfType(AssignmentQuotaExceededException.class) .isThrownBy(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3.getId(), Collections.singletonList(moduleTypeIds.get(quota)))); }
Example 18
Source File: TaskReminderService_Test.java From estatio with Apache License 2.0 | 4 votes |
@Test public void sendReminder() throws Exception { // given final TaskReminderService taskReminderService = new TaskReminderService(); final Person person = new Person(); person.setName("John Doe"); final EmailAddress emailAddress = new EmailAddress(); emailAddress.setEmailAddress("[email protected]"); final PartyRoleType partyRoleType = new PartyRoleType("FOO", "FOO"); final List<Task> overdueTasks = Lists.newArrayList(); overdueTasks.add(new Task(partyRoleType, person, "Description", LocalDateTime.now().minusMonths(1), "", null)); taskReminderService.emailService = mockEmailService; taskReminderService.communicationChannelRepository = mockCommunicationChannelRepository; taskReminderService.deepLinkService = mockDeepLinkService; taskReminderService.clockService = mockClockService; // expect context.checking(new Expectations() {{ oneOf(mockCommunicationChannelRepository).findByOwnerAndType(person, CommunicationChannelType.EMAIL_ADDRESS); will(returnValue(Sets.newTreeSet(Arrays.asList(emailAddress)))); oneOf(mockDeepLinkService).deepLinkFor(overdueTasks.get(0)); will(returnValue(new URI("http://localhost:8080/wicket/entity/task.Task:0"))); oneOf(mockEmailService).send( Arrays.asList("[email protected]"), Lists.emptyList(), Lists.emptyList(), "[email protected]", "You have 1 overdue task in Estatio", "Dear John Doe,\n\nThis is a friendly reminder that you have 1 overdue task(s) in Estatio:\n<ul><li>http://localhost:8080/wicket/entity/task.Task:0</li></ul>"); oneOf(mockClockService).now(); will(returnValue(LocalDate.parse("2018-08-01"))); oneOf(mockCommunicationChannelRepository).findByOwnerAndType(person, CommunicationChannelType.EMAIL_ADDRESS); will(returnValue(Sets.newTreeSet(Arrays.asList(emailAddress)))); oneOf(mockClockService).now(); will(returnValue(LocalDate.parse("2018-08-01"))); }}); // when taskReminderService.sendReminder(person, overdueTasks); // then assertThat(taskReminderService.disableSendReminder(person, overdueTasks)).isEqualTo("A reminder has been sent to John Doe today already"); }
Example 19
Source File: FrameSerializerTest.java From simulacron with Apache License 2.0 | 4 votes |
@Test public void testBatchFrame() throws Exception { // 0x0807062A = CAcGKg== base64 encoded. List<Object> queriesOrIds = Lists.newArrayList( "select * from tbl", new byte[] {0x8, 0x7, 0x6, 0x2A}, "select * from world"); // 0x00 == AA== base64 encoded List<List<ByteBuffer>> values = Lists.newArrayList( Lists.newArrayList(), Lists.newArrayList(ByteBuffer.wrap(new byte[] {0x00})), Lists.newArrayList()); Frame frame = new Frame( 4, false, 10, false, null, Collections.unmodifiableMap(new HashMap<>()), Collections.emptyList(), new Batch((byte) 1, queriesOrIds, values, 2, 10, time, "myks")); String json = writer.writeValueAsString(frame); assertThat(json) .isEqualTo( "{" + System.lineSeparator() + " \"protocol_version\" : 4," + System.lineSeparator() + " \"beta\" : false," + System.lineSeparator() + " \"stream_id\" : 10," + System.lineSeparator() + " \"tracing_id\" : null," + System.lineSeparator() + " \"custom_payload\" : { }," + System.lineSeparator() + " \"warnings\" : [ ]," + System.lineSeparator() + " \"message\" : {" + System.lineSeparator() + " \"type\" : \"BATCH\"," + System.lineSeparator() + " \"opcode\" : 13," + System.lineSeparator() + " \"is_response\" : false," + System.lineSeparator() + " \"type\" : \"UNLOGGED\"," + System.lineSeparator() + " \"queries_or_ids\" : [ \"select * from tbl\", \"CAcGKg==\", \"select * from world\" ]," + System.lineSeparator() + " \"values\" : [ [ ], [ \"AA==\" ], [ ] ]," + System.lineSeparator() + " \"consistency\" : \"TWO\"," + System.lineSeparator() + " \"serial_consistency\" : \"LOCAL_ONE\"," + System.lineSeparator() + " \"default_timestamp\" : 1513196542339," + System.lineSeparator() + " \"keyspace\" : \"myks\"" + System.lineSeparator() + " }" + System.lineSeparator() + "}"); }
Example 20
Source File: GeometryHelperShould.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 3 votes |
@Test public void get_point_from_geometry_from_list() throws D2Error { List<Double> coordinates = Lists.newArrayList(longitude1, latitude1); Geometry geometry = GeometryHelper.createPointGeometry(coordinates); List<Double> point = GeometryHelper.getPoint(geometry); assertThat(point).isEqualTo(coordinates); }