本文整理汇总了Java中org.assertj.core.util.Lists.newArrayList方法的典型用法代码示例。如果您正苦于以下问题:Java Lists.newArrayList方法的具体用法?Java Lists.newArrayList怎么用?Java Lists.newArrayList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.assertj.core.util.Lists
的用法示例。
在下文中一共展示了Lists.newArrayList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTypeExamples
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@DataProvider
public static Object[][] testTypeExamples() {
final List<TypeDeclaration> uriParameters = Lists.newArrayList();
uriParameters.add(new UriParameter("projectKey"));
uriParameters.add(new UriParameter("key"));
uriParameters.add(new UriParameter("ID", "^" + UUID_PATTERN + "$"));
return new Object[][] {
{"https://api.sphere.io/{projectKey}", "https://api.sphere.io/::" + DIRECTORY_PATTERN, uriParameters},
{"https://api.sphere.io/{projectKey}/", "https://api.sphere.io/::" + DIRECTORY_PATTERN, uriParameters},
{"https://api.sphere.io/{projectKey}/test", "https://api.sphere.io/::" + DIRECTORY_PATTERN + "/test", uriParameters},
{"{projectKey}", "::" + DIRECTORY_PATTERN, uriParameters},
{"{projectKey}/", "::" + DIRECTORY_PATTERN, uriParameters},
{"{projectKey}/test", "::" + DIRECTORY_PATTERN + "/test", uriParameters},
{"{projectKey}/{ID}/", "::" + DIRECTORY_PATTERN + "/::" + UUID_PATTERN, uriParameters},
{"/{projectKey}", "::" + DIRECTORY_PATTERN, uriParameters},
{"/{projectKey}/", "::" + DIRECTORY_PATTERN, uriParameters},
{"/{projectKey}/test", "::" + DIRECTORY_PATTERN + "/test", uriParameters},
{"/{projectKey}/{ID}/", "::" + DIRECTORY_PATTERN + "/::" + UUID_PATTERN, uriParameters},
{"/{projectKey}/categories/key={key}/", "::" + DIRECTORY_PATTERN + "/categories/::key=" + DIRECTORY_PATTERN, uriParameters},
};
}
示例2: saveTask
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@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);
}
示例3: testBatchOperations
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void testBatchOperations() {
final Contact contact1 = new Contact("newid1", "newtitle");
final Contact contact2 = new Contact("newid2", "newtitle");
final ArrayList<Contact> contacts = new ArrayList<Contact>();
contacts.add(contact1);
contacts.add(contact2);
repository.save(contacts);
final ArrayList<String> ids = new ArrayList<String>();
ids.add(contact1.getLogicId());
ids.add(contact2.getLogicId());
final List<Contact> result = Lists.newArrayList(repository.findAll(ids));
assertThat(result.size()).isEqualTo(2);
repository.delete(contacts);
final List<Contact> result2 = Lists.newArrayList(repository.findAll(ids));
assertThat(result2.size()).isEqualTo(0);
}
示例4: orderStringWithLambda
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
/**
* lambda 表达式示例
*
* (String o1, String o2) -> {
* return Integer.compare(o1.length(), o2.length());
* }
*
* (o1, o2) -> {
* return Integer.compare(o1.length(), o2.length());
* }
*
* 因为代码块里面的代码只有简单的一句,因此代码块的 {} 也可以省略,而且连 return 语句也可以省略
* (o1, o2) -> Integer.compare(o1.length(), o2.length())
*
* 你可以像对待方法参数一样向 lambda 表达式的参数添加注解或者 final 修饰符
* (final String o1, @NotNull String o2)
*
*/
@Test
public void orderStringWithLambda() {
List<String> strs = Lists.newArrayList("hello", "java", "and", "lambda");
Collections.sort(strs, (String o1, String o2) -> {
return Integer.compare(o1.length(), o2.length());
});
// 因为这里两个参数的类型可以自动推导所以这里参数的类型也可以省略
Collections.sort(strs, (o1, o2) -> {
return Integer.compare(o1.length(), o2.length());
});
// return 语句也不是必须的,不需要 return 是 {} 也可以省略
Collections.sort(strs, (o1, o2) -> Integer.compare(o1.length(), o2.length()));
// 使用 Comparator#comparing 来生成 Comparator
// 这个时候只有一个参数,参数的括号也可以省略
Collections.sort(strs, comparing(str -> str.length()));
// 使用方法引用时,参数也不需要了
Collections.sort(strs, comparing(String::length));
strs.forEach(System.out::println);
}
示例5: canTranslateText
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void canTranslateText() {
List<String> source = Lists.newArrayList("hello");
List<Translation> expectedTrans = Lists.newArrayList(translation);
when(translate.translate(source,
Translate.TranslateOption.targetLanguage("zh"),
Translate.TranslateOption.format("text")))
.thenReturn(expectedTrans);
List<AugmentedTranslation> translations = backend.translate(source,
new GoogleLocaleCode("en"), new GoogleLocaleCode("zh"),
MediaType.TEXT_PLAIN_TYPE, Optional.empty());
assertThat(translations).hasSize(expectedTrans.size());
AugmentedTranslation augmentedTranslation = translations.get(0);
assertThat(augmentedTranslation.getPlainTranslation()).isEqualTo(translation.getTranslatedText());
}
示例6: roundRobinInstanceListWhenWeExperienceIntegerOverflowTest
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void roundRobinInstanceListWhenWeExperienceIntegerOverflowTest() {
// given
InstanceInfo iiMock = mock(InstanceInfo.class);
List<InstanceInfo> instances = Lists.newArrayList(iiMock, iiMock, iiMock);
serviceSpy.vipRoundRobinCounterMap.put("myVip", new AtomicInteger(Integer.MAX_VALUE));
// when
Optional<InstanceInfo> result1 = serviceSpy.roundRobinInstanceList("myVip", instances);
Optional<InstanceInfo> result2 = serviceSpy.roundRobinInstanceList("myVip", instances);
Optional<InstanceInfo> result3 = serviceSpy.roundRobinInstanceList("myVip", instances);
// then
assertThat(result1).isNotEmpty();
assertThat(result2).isNotEmpty();
assertThat(result3).isNotEmpty();
assertThat(serviceSpy.vipRoundRobinCounterMap.get("myVip").intValue()).isEqualTo(1);
}
示例7: shouldReadEntries
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void shouldReadEntries() {
nameChangeAndGroupChangeScenario();
Iterator<Entry> entryIterator = dao.getIterator("by-type", schema, "entry");
List<Entry> entries = Lists.newArrayList(entryIterator);
assertThat(entries.size(), is(7));
Entry entry0 = entries.get(0);
Entry expectedEntry0 = new Entry(91, 91,
Arrays.asList(decode(SHA256, "sha-256:xxx6c4")), timestamp, "UA", EntryType.user);
assertThat(entry0, equalTo(expectedEntry0));
Entry entryLast = entries.get(6);
Entry expectedEntryLast = new Entry(97, 96,
Arrays.asList(decode(SHA256, "sha-256:xxxbdc"),
decode(SHA256, "sha-256:xxx509")), timestamp, "MD", EntryType.user);
assertThat(entryLast, equalTo(expectedEntryLast));
}
示例8: insertList
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
private void insertList() {
List<MyUser> users = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
MyUser myUser = new MyUser();
myUser.setGlobalId(Long.valueOf(i));
myUser.setCookie(COOKIE + i);
myUser.setType(i);
myUser.setUserName(NAME + i);
myUser.setPassword(PASSWORD + i);
myUser.setAge(START_AGE + i);
myUser.setRemainingAmount(new BigDecimal(i));
myUser.setAddTime(new Date());
myUser.setSerialId(Long.valueOf(i));
users.add(myUser);
}
myUserDao.insertList(users);
}
示例9: canGetByUrlAndOptionalOptions
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void canGetByUrlAndOptionalOptions() {
List<Document> expectedResult = Lists.newArrayList(new Document());
when(dao.getByUrl(url, Optional.of(fromLocale.getLocaleCode()),
Optional.of(toLocale.getLocaleCode()),
Optional.empty())).thenReturn(
expectedResult);
List<Document> docs =
service.getByUrl(url, Optional.of(fromLocale.getLocaleCode()),
Optional.of(toLocale.getLocaleCode()),
Optional.empty());
verify(dao).getByUrl(url, Optional.of(fromLocale.getLocaleCode()),
Optional.of(toLocale.getLocaleCode()),
Optional.empty());
assertThat(docs).isSameAs(expectedResult);
}
示例10: canTranslateHTML
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void canTranslateHTML() {
List<String> source = Lists.newArrayList("hello");
List<Translation> expectedTrans = Lists.newArrayList(translation);
when(translate.translate(source,
Translate.TranslateOption.targetLanguage("zh"),
Translate.TranslateOption.format("html")))
.thenReturn(expectedTrans);
List<AugmentedTranslation> translations = backend.translate(source,
new GoogleLocaleCode("en"), new GoogleLocaleCode("zh"),
MediaType.TEXT_HTML_TYPE, Optional.empty());
assertThat(translations).hasSize(expectedTrans.size());
AugmentedTranslation augmentedTranslation = translations.get(0);
assertThat(augmentedTranslation.getPlainTranslation()).isEqualTo(translation.getTranslatedText());
}
示例11: testValidValueLocalization
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void testValidValueLocalization() {
List<String> validValues = Lists.newArrayList();
validValues.add("testVal1");
validValues.add("testVal2");
validValues.add("testVal3");
TestConfigurationProperty testConfigurationProperty = new TestConfigurationProperty(
"configKey", Property.Type.STRING, "name", false,
ConfigurationProperty.Widget.TEXT, "defaultValue", "defaultDescription",
"defaultErrorMessage", validValues, false, false);
List<ConfigurationPropertyValue> localizedValues =
testConfigurationProperty.getValidValues(new TestLocalizer(Locale.getDefault(), ""));
assertThat(localizedValues).hasSize(3);
assertThat(localizedValues.get(0).getValue()).isEqualTo("testVal1");
assertThat(localizedValues.get(0).getLabel()).isEqualTo("testLabel1");
assertThat(localizedValues.get(1).getValue()).isEqualTo("testVal2");
assertThat(localizedValues.get(1).getLabel()).isEqualTo("testLabel2");
assertThat(localizedValues.get(2).getValue()).isEqualTo("testVal3");
assertThat(localizedValues.get(2).getLabel()).isEqualTo("Unknown");
}
示例12: doDistance
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
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;
}
示例13: hasCompositionLemmas
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
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;
}
示例14: convertToSeries
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test
public void convertToSeries() {
// given
QueryResponse response = new QueryResponse();
List<FacetCount> facetCounts = Lists.newArrayList(new FacetCount("facetValue1", 3), new FacetCount("facetValue2", 4));
Series<Object, Integer> series = new Series<Object, Integer>();
XSettings xsettings = mock(XSettings.class);
when(xsettings.getField()).thenReturn(XField.JUDGMENT_DATE);
doReturn(facetCounts).when(xFieldFacetExtractor).extractFacetCounts(response, XField.JUDGMENT_DATE);
doReturn(series).when(facetToSeriesConverter).convert(facetCounts, xsettings);
// execute
Series<Object, Integer> retSeries = seriesResultsConverter.convert(response, xsettings);
// assert
assertTrue(retSeries == series);
verify(xFieldFacetExtractor).extractFacetCounts(response, XField.JUDGMENT_DATE);
verify(facetToSeriesConverter).convert(facetCounts, xsettings);
}
示例15: testMainProcessError
import org.assertj.core.util.Lists; //导入方法依赖的package包/类
@Test(expected = RuntimeException.class)
public void testMainProcessError() throws Exception {
final ProgramOptions programOptions = new ProgramOptions(true, false, false, false, Lists.newArrayList(SECTION_1));
Mockito.doReturn(programOptions).when(programOptionsService).processProgramArgs(Mockito.any(String[].class));
Mockito.doReturn(true).when(startStopService).processAllSections(programOptions);
final String[] arguments = {};
try {
mainService.main(arguments);
}
catch (final Exception e) {
Mockito.verify(programOptionsService).processProgramArgs(arguments);
Mockito.verify(configurationService).loadConfiguration();
Mockito.verify(amazonEC2Service).initialize();
Mockito.verify(startStopService).processAllSections(programOptions);
throw e;
}
}