本文整理汇总了Java中com.jcabi.immutable.ArrayMap类的典型用法代码示例。如果您正苦于以下问题:Java ArrayMap类的具体用法?Java ArrayMap怎么用?Java ArrayMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayMap类属于com.jcabi.immutable包,在下文中一共展示了ArrayMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removesMilestone
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* This tests that MkMilestones can remove a certain MkMilestone, by number.
* @throws Exception - if something goes wrong.
*/
@Test
public void removesMilestone() throws Exception {
final Milestones milestones = new MkGithub().randomRepo()
.milestones();
final Milestone created = milestones.create("testTitle");
MatcherAssert.assertThat(
milestones.iterate(new ArrayMap<String, String>()),
Matchers.<Milestone>iterableWithSize(1)
);
milestones.remove(created.number());
MatcherAssert.assertThat(
milestones.iterate(new ArrayMap<String, String>()),
Matchers.<Milestone>iterableWithSize(0)
);
}
示例2: canHandleMultipleThreads
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* MkGithub can handle multiple threads in parallel.
* @throws Exception if some problem inside
*/
@Test
public void canHandleMultipleThreads() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final int threads = Tv.HUNDRED;
final ExecutorService svc = Executors.newFixedThreadPool(threads);
final Callable<Void> task = new VerboseCallable<Void>(
new Callable<Void>() {
@Override
public Void call() throws Exception {
repo.issues().create("", "");
return null;
}
}
);
final Collection<Callable<Void>> tasks =
new ArrayList<Callable<Void>>(threads);
for (int idx = 0; idx < threads; ++idx) {
tasks.add(task);
}
svc.invokeAll(tasks);
MatcherAssert.assertThat(
repo.issues().iterate(new ArrayMap<String, String>()),
Matchers.<Issue>iterableWithSize(threads)
);
}
示例3: iteratePulls
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* RtPulls can iterate pulls.
* @throws Exception if there is any error
*/
@Test
public void iteratePulls() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
Json.createArrayBuilder()
.add(pull("new-topic"))
.add(pull("Amazing new feature"))
.build().toString()
)
).start();
final RtPulls pulls = new RtPulls(
new ApacheRequest(container.home()),
repo()
);
MatcherAssert.assertThat(
pulls.iterate(new ArrayMap<String, String>()),
Matchers.<Pull>iterableWithSize(2)
);
container.stop();
}
示例4: fetchCommits
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* RtRepoCommits can fetch repo commits.
* @throws Exception if there is no github key provided
*/
@Test
public final void fetchCommits() throws Exception {
final Iterator<RepoCommit> iterator =
RtRepoCommitsITCase.repo().commits().iterate(
new ArrayMap<String, String>()
.with("since", "2014-01-26T00:00:00Z")
.with("until", "2014-01-27T00:00:00Z")
).iterator();
final List<String> shas = new ArrayList<String>(5);
shas.add("1aa4af45aa2c56421c3d911a0a06da513a7316a0");
shas.add("940dd5081fada0ead07762933036bf68a005cc40");
shas.add("05940dbeaa6124e4a87d9829fb2fce80b713dcbe");
shas.add("51cabb8e759852a6a40a7a2a76ef0afd4beef96d");
shas.add("11bd4d527236f9cb211bc6667df06fde075beded");
int found = 0;
while (iterator.hasNext()) {
if (shas.contains(iterator.next().sha())) {
found += 1;
}
}
MatcherAssert.assertThat(
found,
Matchers.equalTo(shas.size())
);
}
示例5: iterateIssues
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* RtIssues can iterate issues.
* @throws Exception if there is any error
*/
@Test
public void iterateIssues() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
Json.createArrayBuilder()
.add(issue("new issue"))
.add(issue("code issue"))
.build().toString()
)
).start();
final RtIssues issues = new RtIssues(
new JdkRequest(container.home()),
repo()
);
MatcherAssert.assertThat(
issues.iterate(new ArrayMap<String, String>()),
Matchers.<Issue>iterableWithSize(2)
);
container.stop();
}
示例6: iteratesIssues
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* RtIssues can iterate issues.
* @throws Exception If some problem inside
*/
@Test
public void iteratesIssues() throws Exception {
final Iterable<Issue.Smart> issues = new Smarts<Issue.Smart>(
new Bulk<Issue>(
repo.issues().iterate(
new ArrayMap<String, String>().with("sort", "comments")
)
)
);
for (final Issue.Smart issue : issues) {
MatcherAssert.assertThat(
issue.title(),
Matchers.notNullValue()
);
}
}
示例7: add
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
@Override
public void add(final String name) throws IOException {
final Collection<String> friends = this.list();
friends.add(name);
final Ocket ocket = this.bucket.ocket(this.key());
final ObjectMetadata meta = ocket.meta();
meta.setUserMetadata(
new ArrayMap<>(meta.getUserMetadata()).with(
AwsFriends.HEADER,
Joiner.on(';').join(friends)
)
);
ocket.bucket().region().aws().copyObject(
new CopyObjectRequest(
ocket.bucket().name(),
ocket.key(),
ocket.bucket().name(),
ocket.key()
).withNewObjectMetadata(meta)
);
final ObjectMetadata fmeta = new ObjectMetadata();
fmeta.addUserMetadata(AwsDoc.HEADER, "true");
this.bucket.ocket(String.format("%s/%s", name, this.label)).write(
IOUtils.toInputStream(""), fmeta
);
}
示例8: eject
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
@Override
public void eject(final String name) throws IOException {
final Collection<String> friends = this.list();
friends.remove(name);
final Ocket ocket = this.bucket.ocket(this.key());
final ObjectMetadata meta = ocket.meta();
meta.setUserMetadata(
new ArrayMap<>(meta.getUserMetadata()).with(
AwsFriends.HEADER,
Joiner.on(';').join(friends)
)
);
ocket.bucket().region().aws().copyObject(
new CopyObjectRequest(
ocket.bucket().name(),
ocket.key(),
ocket.bucket().name(),
ocket.key()
).withNewObjectMetadata(meta)
);
this.bucket.remove(String.format("%s/%s", name, this.label));
}
示例9: enter
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
@Override
public Opt<Identity> enter(final Request req) throws IOException {
final Opt<Identity> user;
if (TkAppAuth.TESTING) {
final Iterator<String> login =
new RqHref.Base(req).href().param("user").iterator();
final String name;
if (login.hasNext()) {
name = login.next();
} else {
name = "tester";
}
user = new Opt.Single<Identity>(
new Identity.Simple(
String.format("urn:test:%s", name),
new ArrayMap<String, String>().with("login", name)
)
);
} else {
user = new Opt.Empty<>();
}
return user;
}
示例10: ports
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* Detect all ports.
* @param name Docker container name
* @param host Host name of the tank
* @return Ports
* @throws IOException If fails
*/
private Map<String, Integer> ports(final String name, final String host)
throws IOException {
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>(0);
final String stdout = this.script.exec(
host,
new ArrayMap<String, String>().with("container", name)
);
final Matcher matcher = DetectPorts.PTN.matcher(stdout);
while (matcher.find()) {
map.put(
matcher.group(1),
Integer.parseInt(matcher.group(2))
);
}
Logger.info(
this, "Docker container %s at %s exposes these ports: %s",
name, host, map
);
return map;
}
示例11: SimpleLink
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* Public ctor (parser).
* @param text Text to parse
* @throws IOException If fails
*/
SimpleLink(final String text) throws IOException {
final Matcher matcher = WebLinkingResponse.SimpleLink.PTN
.matcher(text);
if (!matcher.matches()) {
throw new IOException(
String.format(
"Link header value doesn't comply to RFC-5988: \"%s\"",
text
)
);
}
this.addr = matcher.group(1);
final ConcurrentMap<String, String> args =
new ConcurrentHashMap<>(0);
for (final String pair
: matcher.group(2).trim().split("\\s*;\\s*")) {
final String[] parts = pair.split("=");
args.put(
parts[0].trim().toLowerCase(Locale.ENGLISH),
parts[1].trim().replaceAll("(^\"|\"$)", "")
);
}
this.params = new ArrayMap<>(args);
}
示例12: Compiler
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* Ctor.
* @param src Directory with sources
* @param dest Directory to write output
* @param props Properties
* @throws IOException If fails
* @since 1.14
*/
public Compiler(@NotNull final File src, @NotNull final File dest,
@NotNull final Map<String, String> props) throws IOException {
this.input = src.getAbsolutePath();
this.output = dest.getAbsolutePath();
this.properties = new ArrayMap<String, String>(props);
if (!src.exists()) {
throw new IOException(
String.format("directory \"%s\" is absent", this.input)
);
}
if (dest.mkdirs()) {
Logger.info(
Compiler.class, "output directory \"%s\" created",
this.output
);
}
}
示例13: addsMapOfValues
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* Directives can add map of values.
* @throws Exception If some problem inside
* @since 0.8
*/
@Test
public void addsMapOfValues() throws Exception {
final Document dom = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
dom.appendChild(dom.createElement("root"));
new Xembler(
new Directives().xpath("/root").add(
new ArrayMap<String, Object>()
.with("first", 1)
.with("second", "two")
).add("third")
).apply(dom);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(dom),
XhtmlMatchers.hasXPaths(
"/root/first[.=1]",
"/root/second[.='two']",
"/root/third"
)
);
}
示例14: iteratesMilestones
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* This tests that the iterate(Map<String, String> params)
* method in MkMilestones works fine.
* @throws Exception - if something goes wrong.
*/
@Test
public void iteratesMilestones() throws Exception {
final Milestones milestones = new MkGithub().randomRepo()
.milestones();
milestones.create("testMilestone");
MatcherAssert.assertThat(
milestones.iterate(new ArrayMap<String, String>()),
Matchers.<Milestone>iterableWithSize(1)
);
}
示例15: iteratesIssues
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* MkIssues can list issues.
* @throws Exception If some problem inside
*/
@Test
public void iteratesIssues() throws Exception {
final Repo repo = new MkGithub().randomRepo();
repo.issues().create("hey, you", "body of issue");
repo.issues().create("hey", "body of 2nd issue");
repo.issues().create("hey again", "body of 3rd issue");
MatcherAssert.assertThat(
repo.issues().iterate(new ArrayMap<String, String>()),
Matchers.<Issue>iterableWithSize(Tv.THREE)
);
}