/** @see DATAREST-609 */
  @Test
  public void addsSelfAndSingleResourceLinkToResourceByDefault() throws Exception {

    Projector projector = mock(Projector.class);

    when(projector.projectExcerpt(anyObject())).thenAnswer(new ReturnsArgumentAt(0));

    PersistentEntityResourceAssembler assembler =
        new PersistentEntityResourceAssembler(
            entities,
            projector,
            associations,
            new DefaultSelfLinkProvider(
                entities, entityLinks, Collections.<EntityLookup<?>>emptyList()));

    User user = new User();
    user.id = BigInteger.valueOf(4711);

    PersistentEntityResource resource = assembler.toResource(user);

    Links links = new Links(resource.getLinks());

    assertThat(links, is(Matchers.<Link>iterableWithSize(2)));
    assertThat(links.getLink("self").getVariables(), is(Matchers.empty()));
    assertThat(links.getLink("user").getVariableNames(), is(hasItem("projection")));
  }
  @Test
  public void requestsSingularBuildChangesForTeamCitySevenApi() {
    final BuildDetail buildDetail = buildDetail(1);
    channel.respondingWith(
        "http://foo" + buildDetail.changes.href, contentFrom("tc_7.0.0_changes_1.json"));

    final List<Change> changes = communicator.changesOf(buildDetail);
    assertThat(changes, is(Matchers.<Change>iterableWithSize(1)));
    assertThat(changes.get(0).id, is("62889"));
  }
  @Test
  public void appliesGivenRegularExpressionToFilterOutClassNames() throws Exception {
    String[] resources = {"com/some/classfile/FindMe.class", "com/some/classfile/IgnoreThis.class"};
    NamesFromClassResources toAnalyse = new NamesFromClassResources(".*FindMe.*");

    assertThat(
        toAnalyse.asDotted(resources),
        allOf(
            contains(aDottedClassNameOf("com.some.classfile.FindMe")),
            Matchers.<Dotted>iterableWithSize(1)));
  }
  @Test
  public void requestsMultipleBuildChangesForTeamCitySixApi() {
    final BuildDetail buildDetail = buildDetail(2);
    channel.respondingWith(
        "http://foo" + buildDetail.changes.href,
        contentFrom("tc_6.5.5_changes_2.json").replace("@", ""));

    final List<Change> changes = communicator.changesOf(buildDetail);
    assertThat(changes, is(Matchers.<Change>iterableWithSize(2)));
    assertThat(changes.get(0).id, is("47951"));
    assertThat(changes.get(1).id, is("47949"));
  }
Пример #5
0
 /**
  * AwsUser can work with real data.
  *
  * @throws Exception If some problem inside
  */
 @Test
 public void worksWithRealDynamoDb() throws Exception {
   final URN urn = new URN("urn:github:66");
   final User user = new AwsUser(this.region, Mockito.mock(SQSClient.class), urn);
   MatcherAssert.assertThat(user.urn(), Matchers.equalTo(urn));
   for (Rule rule : user.rules()) {
     user.rules().remove(rule.name());
   }
   final String name = "simple-rule";
   user.rules().create(name);
   MatcherAssert.assertThat(user.rules(), Matchers.<Rule>iterableWithSize(1));
   MatcherAssert.assertThat(user.rules().contains(name), Matchers.is(true));
 }
  /** @see DATAREST-394, DATAREST-408 */
  @Test
  @SuppressWarnings("unchecked")
  public void appliesProjectionToNonEmptyMap() throws Throwable {

    MethodInterceptor methodInterceptor =
        new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor);

    Object result =
        methodInterceptor.invoke(
            mockInvocationOf("getHelperMap", Collections.singletonMap("foo", mock(Helper.class))));

    assertThat(result, is(instanceOf(Map.class)));

    Map<String, Object> projections = (Map<String, Object>) result;
    assertThat(projections.entrySet(), is(Matchers.<Entry<String, Object>>iterableWithSize(1)));
    assertThat(projections, hasEntry(is("foo"), instanceOf(HelperProjection.class)));
  }