本文整理汇总了Java中com.jcabi.immutable.ArrayMap类的典型用法代码示例。如果您正苦于以下问题:Java ArrayMap类的具体用法?Java ArrayMap怎么用?Java ArrayMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayMap类属于com.jcabi.immutable包,在下文中一共展示了ArrayMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
);
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:20,代码来源:MkMilestonesTest.java
示例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)
);
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:30,代码来源:MkGithubTest.java
示例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();
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:26,代码来源:RtPullsTest.java
示例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())
);
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:30,代码来源:RtRepoCommitsITCase.java
示例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();
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:26,代码来源:RtIssuesTest.java
示例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()
);
}
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:21,代码来源:RtIssuesITCase.java
示例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
);
}
开发者ID:libreio,项目名称:libre,代码行数:27,代码来源:AwsFriends.java
示例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));
}
开发者ID:libreio,项目名称:libre,代码行数:23,代码来源:AwsFriends.java
示例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;
}
开发者ID:yegor256,项目名称:thindeck,代码行数:24,代码来源:TkAppAuth.java
示例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;
}
开发者ID:yegor256,项目名称:thindeck,代码行数:28,代码来源:DetectPorts.java
示例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);
}
开发者ID:jcabi,项目名称:jcabi-http,代码行数:30,代码来源:WebLinkingResponse.java
示例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
);
}
}
开发者ID:yegor256,项目名称:requs,代码行数:26,代码来源:Compiler.java
示例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"
)
);
}
开发者ID:yegor256,项目名称:xembly,代码行数:27,代码来源:DirectivesTest.java
示例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)
);
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:16,代码来源:MkMilestonesTest.java
示例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)
);
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:16,代码来源:MkIssuesTest.java
示例16: deleteMilestone
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* RtMilestones can remove a milestone.
* @throws Exception if some problem inside
*/
@Test
public void deleteMilestone() throws Exception {
final Milestones milestones = repo.milestones();
final Milestone milestone = milestones.create("a milestones");
MatcherAssert.assertThat(
milestones.iterate(new ArrayMap<String, String>()),
Matchers.hasItem(milestone)
);
milestones.remove(milestone.number());
MatcherAssert.assertThat(
milestones.iterate(new ArrayMap<String, String>()),
Matchers.not(Matchers.hasItem(milestone))
);
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:19,代码来源:RtMilestonesITCase.java
示例17: exec
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
@Override
public void exec(final Iterable<Deck> decks) throws IOException {
this.script.exec(
"t1.thindeck.com",
new ArrayMap<String, String>()
);
}
开发者ID:yegor256,项目名称:thindeck,代码行数:8,代码来源:SetupNginx.java
示例18: exec
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
@Override
public void exec(final Iterable<Deck> decks) throws IOException {
final Iterable<String> confs = Iterables.concat(
Iterables.transform(
decks,
new Function<Deck, Iterable<String>>() {
@Override
public Iterable<String> apply(final Deck deck) {
try {
return Iterables.transform(
new Deck.Smart(deck).xml().xpath(
"/deck/domains/domain/text()"
),
new Function<String, String>() {
@Override
public String apply(final String dmn) {
return String.format("%s.conf", dmn);
}
}
);
} catch (final IOException ex) {
throw new IllegalStateException(ex);
}
}
}
)
);
final String host = "t1.thindeck.com";
final Shell shell = new Remote(host);
shell.exec(
"cat > ~/domains",
IOUtils.toInputStream(Joiner.on('\n').join(confs)),
new ByteArrayOutputStream(),
new ByteArrayOutputStream()
);
new Script.Default(SetupNginx.class.getResource("clean-nginx.sh")).exec(
host, new ArrayMap<String, String>()
);
}
开发者ID:yegor256,项目名称:thindeck,代码行数:40,代码来源:CleanNginx.java
示例19: update
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* Update for one domain.
* @param domain Domain name
* @param deck The deck
* @throws IOException If fails
*/
private void update(final String domain, final XML deck)
throws IOException {
// @checkstyle LineLength (1 line)
final String terms = "not(@waste) and @type='green' and @state='alive' and http";
final String servers = Joiner.on(' ').join(
Iterables.transform(
deck.nodes(String.format("//container[%s]", terms)),
new Function<XML, String>() {
@Override
public String apply(final XML ctr) {
return String.format(
"server %s:%s; ",
ctr.xpath("host/text()").get(0),
ctr.xpath("http/text()").get(0)
);
}
}
)
);
this.script.exec(
"t1.thindeck.com",
new ArrayMap<String, String>()
.with("deck", deck.xpath("/deck/@name").get(0))
.with(
"images",
Joiner.on(',').join(
deck.xpath(
String.format("//container[%s]/image/text()", terms)
)
)
)
.with("port", "80")
.with("group", domain.replace(".", "_"))
.with("domain", domain)
.with("servers", servers)
);
}
开发者ID:yegor256,项目名称:thindeck,代码行数:44,代码来源:UpdateNginx.java
示例20: terminate
import com.jcabi.immutable.ArrayMap; //导入依赖的package包/类
/**
* Terminate docker container.
* @param host Host
* @param name Name of container
* @throws IOException If fails
*/
private void terminate(final String host, final String name)
throws IOException {
this.script.exec(
host,
new ArrayMap<String, String>().with("container", name)
);
Logger.info(
StartDocker.class,
"Docker container %s terminated at %s", name, host
);
}
开发者ID:yegor256,项目名称:thindeck,代码行数:18,代码来源:TerminateDocker.java
注:本文中的com.jcabi.immutable.ArrayMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论