Java Code Examples for org.osgl.util.S#random()
The following examples show how to use
org.osgl.util.S#random() .
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: PropertyTest.java From java-tool with Apache License 2.0 | 6 votes |
@Test public void testSetProperty() { Foo foo = new Foo(); String s1 = S.random(); $.setProperty(foo, s1, "s"); eq(s1, foo.getS()); String s2 = S.random(); $.setProperty(foo, s2, "bar.s"); eq(s2, foo.bar.s); boolean b = !foo.bar.b; $.setProperty(foo, b, "bar.b"); eq(b, foo.bar.b); String s3 = S.random(); $.setProperty(foo, s3, "barList[][s]"); eq(s3, foo.barList.get(0).s()); }
Example 2
Source File: PropertyTest.java From java-tool with Apache License 2.0 | 6 votes |
@Test public void testGetProperty() { String s1 = S.random(); String s2 = S.random(); int i = N.randInt(); boolean b = false; Foo foo = new Foo(s1, i, s2, b); eq(s1, $.getProperty(foo, "s")); eq(s2, $.getProperty(foo, "bar.s")); eq(s1, $.getProperty(foo, "baseId")); eq(i, $.getProperty(foo, "i")); eq(false, $.getProperty(foo, "bar/b")); eq(false, $.getProperty(foo, "bar.b")); eq(null, $.getProperty(foo, "barList")); Bar bar = new Bar("bar", true); foo.addBar(bar); eq(bar, ((List)$.getProperty(foo, "barList")).get(0)); eq(bar.s(), $.getProperty(foo, "barList.0.s")); eq("red", $.getProperty(foo, "barList[0][colors][R]")); }
Example 3
Source File: Gh208.java From java-tool with Apache License 2.0 | 6 votes |
@Test public void test() { Bar source = new Bar(); source.name = S.random(); Foo foo = new Foo(); foo.name = S.random(); foo.level = N.randInt(); foo.flag = true; source.foo = foo; Bar target = $.deepCopy(source).filter("-foo,+foo.name").to(Bar.class); eq(source.name, target.name); Foo targetFoo = target.foo; notNull(targetFoo); eq(foo.name, targetFoo.name); eq(0, targetFoo.level); no(targetFoo.flag); }
Example 4
Source File: LangTest.java From java-tool with Apache License 2.0 | 5 votes |
@Test public void testConvertExtension() { TypeConverterRegistry.INSTANCE .register(new MyConverter()) .register(new StringToMyFrom()); String id = S.random(); eq(new MyTo(id), $.convert(new MyFrom(id)).to(MyTo.class)); eq("abc", $.convert("abc").to(MyTo.class).toString()); }
Example 5
Source File: FuncTestBase.java From java-tool with Apache License 2.0 | 5 votes |
@Before public void setup() { rs1 = S.random(); rs2 = S.random(); rs3 = S.random(); rs4 = S.random(); rs5 = S.random(); }
Example 6
Source File: Gh209.java From java-tool with Apache License 2.0 | 5 votes |
@Test public void test() { Bar source = new Bar(); source.name = S.random(); Foo foo = new Foo(); foo.name = S.random(); foo.level = N.randInt(); foo.flag = true; source.foo = foo; Bar target = $.cloneOf(source); }
Example 7
Source File: Gh202.java From java-tool with Apache License 2.0 | 5 votes |
@Test public void test() { Bean bean = new Bean(); Map<String, Object> innerMap = C.Map("count", 1); bean.map = C.Map("foo", "bar", "inner", innerMap); bean.name = S.random(); Bean target = $.deepCopy(bean).filter("map").to(Bean.class); Map<String, Object> innerMap2 = $.cast(target.map.get("inner")); notNull(innerMap2); eq(1, innerMap2.get("count")); }
Example 8
Source File: StringConcatBenchmark.java From java-tool with Apache License 2.0 | 5 votes |
@BeforeClass public static void prepare() { s1 = S.random(); s2 = S.random(); s3 = S.random(); s4 = S.random(); s5 = S.random(); s6 = S.random(); s12 = s1 + s2; i12 = s12.length(); s123 = s12 + s3; i123 = s123.length(); s123456 = s123 + s4 + s5 + s6; i123456 = s123456.length(); }
Example 9
Source File: ContentSuffixSensor.java From actframework with Apache License 2.0 | 5 votes |
private static List<String> prepareUrlList() { final int size = 100; List<String> suffixes = C.listOf(".json,/json,.xml,/xml,.csv,/csv".split(",")); if (null == generated) { generated = new ArrayList<String>(size); for (int i = 0; i < size; ++i) { String url = S.random(30 + N.randInt(40)); if (i % 2 == 0) { url += $.random(suffixes); } generated.add(url); } } return generated; }
Example 10
Source File: StringSecureTicketCodecTest.java From actframework with Apache License 2.0 | 5 votes |
@Test public void test() { H.Session session = new H.Session(); String foo = S.random(); session.put("foo", foo); prepareSession(session); StringSecureTicketCodec codec = codec(); String ticket = codec.createTicket(session); H.Session session2 = codec.parseTicket(ticket); verifySession(session, session2); }
Example 11
Source File: Person2.java From actframework with Apache License 2.0 | 5 votes |
public Person2(String fn, String ln, Address2 addr, Integer age, Gender gender) { firstName = fn; lastName = ln; address = addr; this.age = age; this.gender = gender; this.height = 178; v1 = S.random(); }
Example 12
Source File: VersionedModel.java From actframework with Apache License 2.0 | 4 votes |
public VersionedModel(String id) { this.version = S.blank(id) ? S.random() : id; }
Example 13
Source File: VersionedModel.java From actframework with Apache License 2.0 | 4 votes |
public VersionedModel() { this(S.random()); }
Example 14
Source File: RandomStringProvider.java From actframework with Apache License 2.0 | 4 votes |
@Override public String get() { return S.random(2 + N.randInt(20)); }
Example 15
Source File: Zee.java From java-tool with Apache License 2.0 | 4 votes |
public Zee() { super("zee-" + S.random(5)); i = new Random().nextInt(10000); }
Example 16
Source File: Bar.java From java-tool with Apache License 2.0 | 4 votes |
public Bar() { super("bar-" + S.random(3)); id = S.random(10); }
Example 17
Source File: DataTableTest.java From actframework with Apache License 2.0 | 4 votes |
private static Foo randomFoo() { String name = S.random(); int count = N.randInt(); return new Foo(name, count); }
Example 18
Source File: TestBase.java From java-tool with Apache License 2.0 | 4 votes |
protected static String newRandStr() { return S.random(new Random().nextInt(30) + 15); }
Example 19
Source File: ActEventListenerBase.java From actframework with Apache License 2.0 | 4 votes |
private static String genId() { return S.random(3) + ID_.getAndIncrement(); }
Example 20
Source File: StringListProvider.java From actframework with Apache License 2.0 | 4 votes |
protected String randomStr() { return null == stringList || stringList.isEmpty() ? S.random() : $.random(stringList); }