本文整理汇总了Java中org.dmfs.iterables.elementary.Seq类的典型用法代码示例。如果您正苦于以下问题:Java Seq类的具体用法?Java Seq怎么用?Java Seq使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Seq类属于org.dmfs.iterables.elementary包,在下文中一共展示了Seq类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEmpty
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testEmpty()
{
InsertOperation<Object> mockOp = mock(InsertOperation.class);
when(mockOp.contentOperationBuilder(any(TransactionContext.class))).then(new Answer<ContentProviderOperation.Builder>()
{
@Override
public ContentProviderOperation.Builder answer(InvocationOnMock invocation) throws Throwable
{
return ContentProviderOperation.newInsert(Uri.EMPTY);
}
});
assertThat(new MultiInsertBatch<>(mockOp, new Seq<RowData<Object>>()), emptyIterable());
assertThat(new MultiInsertBatch<>(mockOp, Absent.<RowData<Object>>absent()), emptyIterable());
assertThat(new MultiInsertBatch<>(mockOp, Absent.<RowData<Object>>absent(), Absent.<RowData<Object>>absent()), emptyIterable());
}
示例2: testContentLength
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testContentLength() throws UnsupportedEncodingException
{
assertThat(new XWwwFormUrlEncodedEntity(
new EmptyIterable<Pair<CharSequence, CharSequence>>()).contentLength(), isPresent(0L));
assertThat(new XWwwFormUrlEncodedEntity(
new Seq<Pair<CharSequence, CharSequence>>(new ValuePair<CharSequence, CharSequence>("key", "valueäöü"))).contentLength(),
isPresent((long) "key=value%C3%A4%C3%B6%C3%BC".getBytes("UTF-8").length));
assertThat(new XWwwFormUrlEncodedEntity(
new Seq<Pair<CharSequence, CharSequence>>(
new ValuePair<CharSequence, CharSequence>("key1", "valueäöü"),
new ValuePair<CharSequence, CharSequence>("key2", "value/+ "))).contentLength(),
isPresent((long) "key1=value%C3%A4%C3%B6%C3%BC&key2=value%2F%2B+".getBytes("UTF-8").length));
}
示例3: iterator
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Override
public Iterator<Single<ContentValues>> iterator()
{
Optional<DateTime> start = new NullSafe<>(mTaskAdapter.valueOf(TaskAdapter.DTSTART));
// effective due is either the actual due, start + duration or absent
Optional<DateTime> effectiveDue = new FirstPresent<>(
new Seq<>(
new NullSafe<>(mTaskAdapter.valueOf(TaskAdapter.DUE)),
new Zipped<>(start, new NullSafe<>(mTaskAdapter.valueOf(TaskAdapter.DURATION)), DateTime::addDuration)));
Single<ContentValues> baseData = new Distant(mTaskAdapter.valueOf(TaskAdapter.IS_CLOSED) ? -1 : 0,
new Enduring(new DueDated(effectiveDue, new StartDated(start, new VanillaInstanceData()))));
// TODO: implement support for recurrence, for now we only return the first instance
return new SingletonIterator<>(mTaskAdapter.isRecurring() ?
new Overridden(new NullSafe<>(mTaskAdapter.valueOf(TaskAdapter.ORIGINAL_INSTANCE_TIME)), baseData)
:
baseData);
}
示例4: setUp
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Before
public void setUp() throws Exception
{
mContext = InstrumentationRegistry.getTargetContext();
mResolver = mContext.getContentResolver();
mAuthority = AuthorityUtil.taskAuthority(mContext);
mClient = mContext.getContentResolver().acquireContentProviderClient(mAuthority);
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
queue.enqueue(new Seq<Operation<?>>(
new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
示例5: testSingleInsert
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
/**
* Create 1 local task list and 1 task, check values in TaskLists, Tasks, Instances tables.
*/
@Test
public void testSingleInsert()
{
RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
assertThat(new Seq<>(
new Put<>(taskList, new NameData("list1")),
new Put<>(task, new TitleData("task1"))
), resultsIn(mClient,
new Assert<>(taskList, new NameData("list1")),
new Assert<>(task, new TitleData("task1")),
new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
new Composite<Instances>(
new InstanceTestData(0),
new CharSequenceRowData<>(Tasks.TZ, null))
)));
}
示例6: testSingleInsertUpdateInstance
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
/**
* Create 1 local task list and 1 task, update task via instances table and check values in TaskLists, Tasks, Instances tables.
*/
@Test
public void testSingleInsertUpdateInstance()
{
RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
Table<Instances> instancesTable = new InstanceTable(mAuthority);
assertThat(new Seq<>(
new Put<>(taskList, new NameData("list1")),
new Put<>(task, new TitleData("task1")),
new BulkUpdate<>(instancesTable, new CharSequenceRowData<>(Tasks.TITLE, "task updated"), new ReferringTo<>(Instances.TASK_ID, task))
), resultsIn(mClient,
new Assert<>(taskList, new NameData("list1")),
new Assert<>(task, new TitleData("task updated")),
new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
new Composite<Instances>(
new InstanceTestData(0),
new CharSequenceRowData<>(Tasks.TZ, null))
)));
}
示例7: testInstanceDelete
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
/**
* Having a single task.
* Delete task, check that it is removed from Tasks and Instances tables.
*/
@Test
public void testInstanceDelete() throws Exception
{
RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table<Tasks> taskTable = new TaskListScoped(taskList, new TasksTable(mAuthority));
RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(taskTable);
OperationsQueue queue = new BasicOperationsQueue(mClient);
queue.enqueue(new Seq<>(
new Put<>(taskList, new NameData("list1")),
new Put<>(task, new TitleData("task1"))
));
queue.flush();
assertThat(new SingletonIterable<>(
new Delete<>(task)
), resultsIn(queue,
new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))
));
}
示例8: testDeleteInstance
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
/**
* Having a single task.
* Delete the instance of that task, check that it is removed from Tasks and Instances tables.
*/
@Test
public void testDeleteInstance() throws Exception
{
RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table<Tasks> taskTable = new TaskListScoped(taskList, new TasksTable(mAuthority));
Table<Instances> instancesTable = new InstanceTable(mAuthority);
RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(taskTable);
OperationsQueue queue = new BasicOperationsQueue(mClient);
queue.enqueue(new Seq<>(
new Put<>(taskList, new NameData("list1")),
new Put<>(task, new TitleData("task1"))
));
queue.flush();
// check that removing the instance removes task and instance
assertThat(new SingletonIterable<>(
new BulkDelete<>(instancesTable, new ReferringTo<>(Instances.TASK_ID, task))
), resultsIn(queue,
new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))
));
}
示例9: testDeleteSingleInstance
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
/**
* Create a single instance and delete it.
*/
@Test
public void testDeleteSingleInstance()
{
RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot<Instances> instance = new VirtualRowSnapshot<>(new InstanceTable(mAuthority));
assertThat(new Seq<>(
// create a local list
new Put<>(taskList, new NameData("list1")),
// insert a new task straight into the instances table
new Put<>(instance, new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
// delete the instance
new Delete<>(instance)
), resultsIn(mClient,
new Assert<>(taskList, new NameData("list1")),
// the list does not contain a single task
new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
}
示例10: testOperations
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testOperations() throws Exception
{
Operation<?> mockOp1 = mock(Operation.class);
Operation<?> mockOp2 = mock(Operation.class);
Operation<?> mockOp3 = mock(Operation.class);
doReturn(ContentProviderOperation.newUpdate(Uri.EMPTY)).when(mockOp1).contentOperationBuilder(ArgumentMatchers.any(TransactionContext.class));
// every last operation of each batch should allow yielding
assertThat(new Yieldable(new SingletonIterable<Operation<?>>(mockOp1)),
Matchers.contains(
builds(
updateOperation(),
withoutValues(),
withoutExpectedCount(),
withYieldAllowed())));
assertThat(new Yieldable(new Seq<>(mockOp1, mockOp2)),
Matchers.contains(
builds(
updateOperation(),
withoutValues(),
withoutExpectedCount(),
withYieldAllowed()),
Matchers.<Operation>is(mockOp2)));
assertThat(new Yieldable(new Seq<>(mockOp1, mockOp2, mockOp3)),
Matchers.contains(
builds(
updateOperation(),
withoutValues(),
withoutExpectedCount(),
withYieldAllowed()),
Matchers.<Operation>is(mockOp2),
Matchers.<Operation>is(mockOp3)));
}
示例11: testEmpty
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testEmpty() throws Exception
{
assertThat(new Composite<>(new Seq<Projection<Contract>>(new EmptyProjection<Contract>())), projectsEmpty());
assertThat(new Composite<>(new Seq<Projection<Contract>>(new EmptyProjection<Contract>(), new EmptyProjection())), projectsEmpty());
assertThat(new Composite<>(new Seq<Projection<Contract>>(new EmptyProjection<Contract>(), new EmptyProjection(), new EmptyProjection())),
projectsEmpty());
}
示例12: testNonEmpty
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testNonEmpty() throws Exception
{
assertThat(new Composite<>(new Seq<Projection<Contract>>(new MultiProjection<Contract>("abc"))), projects("abc"));
assertThat(new Composite<>(new Seq<Projection<Contract>>(new MultiProjection<Contract>("abc", "xyz", "qrs"))), projects("abc", "xyz", "qrs"));
assertThat(new Composite<>(new Seq<Projection<Contract>>(new MultiProjection<Contract>("abc"), new MultiProjection<Contract>("xyz"))),
projects("abc", "xyz"));
assertThat(new Composite<>(new Seq<Projection<Contract>>(new MultiProjection<Contract>("abc", "xyz", "qrs"))), projects("abc", "xyz", "qrs"));
assertThat(new Composite<>(
new Seq<Projection<Contract>>(new MultiProjection<Contract>("abc", "xyz", "qrs"), new MultiProjection<Contract>("123", "456", "789"))),
projects("abc", "xyz", "qrs", "123", "456", "789"));
}
示例13: testDuplicateColumns
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testDuplicateColumns() throws Exception
{
assertThat(new Composite<>(
new Seq<Projection<Contract>>(
new MultiProjection<Contract>("abc", "xyz", "qrs", "123", "456", "789"),
new MultiProjection<Contract>("abc", "xyz", "qrs", "123", "456", "789"))),
projects("abc", "xyz", "qrs", "123", "456", "789", "abc", "xyz", "qrs", "123", "456", "789"));
}
示例14: testUtf8Content
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testUtf8Content() throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
new XWwwFormUrlEncodedEntity(new Seq<Pair<CharSequence, CharSequence>>(new ValuePair<CharSequence, CharSequence>("key", "valueäöü"))).writeContent(out);
assertThat(out.toByteArray(), is("key=value%C3%A4%C3%B6%C3%BC".getBytes("utf-8")));
}
示例15: testUtf8Content2
import org.dmfs.iterables.elementary.Seq; //导入依赖的package包/类
@Test
public void testUtf8Content2() throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
new XWwwFormUrlEncodedEntity(new Seq<Pair<CharSequence, CharSequence>>(
new ValuePair<CharSequence, CharSequence>("key1", "valueäöü"),
new ValuePair<CharSequence, CharSequence>("key2", "value/+ "))).writeContent(out);
assertThat(out.toByteArray(), is("key1=value%C3%A4%C3%B6%C3%BC&key2=value%2F%2B+".getBytes("utf-8")));
}