Example #1
0
  @Test
  public void testPutFacilityUuid() throws Exception {
    OrganisationUnit organisationUnit = createOrganisationUnit('A');
    manager.save(organisationUnit);

    Facility facility = new OrganisationUnitToFacilityConverter().convert(organisationUnit);
    facility.setName("FacilityB");
    facility.setActive(false);

    MockHttpSession session = getSession("ALL");

    mvc.perform(
            put("/fred/v1/facilities/" + organisationUnit.getUuid())
                .content(objectMapper.writeValueAsString(facility))
                .session(session)
                .contentType(MediaType.APPLICATION_JSON))
        .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.uuid", Matchers.notNullValue()))
        .andExpect(jsonPath("$.name").value("FacilityB"))
        .andExpect(jsonPath("$.active").value(false))
        .andExpect(jsonPath("$.createdAt", Matchers.notNullValue()))
        .andExpect(jsonPath("$.updatedAt", Matchers.notNullValue()))
        .andExpect(header().string("ETag", Matchers.notNullValue()))
        .andExpect(status().isOk());
  }
  @Test
  public void sessionIMChatAccept8()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 3 has received a chat message");

    receiveMessageStatusURL = INVALID;

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("I am good"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem(sessionID),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser4Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    Setup.endTest();
  }
  @Test
  public void sessionIMChatAccept1A() {
    Setup.startTest("Checking IM notifications for user 4");
    String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.chatSessionInvitationNotification", Matchers.notNullValue(),
                "notificationList.messageNotification.dateTime", Matchers.notNullValue(),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress[0]",
                    Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)))
            .post(url);
    System.out.println(
        "Response = " + notifications4.getStatusCode() + " / " + notifications4.asString());

    JsonPath jsonData = notifications4.jsonPath();

    receiveSessionURL =
        jsonData.getString("notificationList.chatSessionInvitationNotification[0].link[0].href");
    System.out.println("Extracted receiveSessionURL=" + receiveSessionURL);

    receiveSessionID = jsonData.getString("notificationList.messageNotification.sessionId[0]");
    System.out.println("Extracted receiveSessionID=" + receiveSessionID);

    receiveMessageID = jsonData.getString("notificationList.messageNotification.messageId[0]");
    System.out.println("Extracted receiveMessageID=" + receiveMessageID);

    Setup.endTest();
  }
Example #4
0
  public void testEmptyAggregation() throws Exception {
    SearchResponse searchResponse =
        client()
            .prepareSearch("empty_bucket_idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                histogram("histo")
                    .field("value")
                    .interval(1L)
                    .minDocCount(0)
                    .subAggregation(nested("nested", "nested")))
            .execute()
            .actionGet();

    assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L));
    Histogram histo = searchResponse.getAggregations().get("histo");
    assertThat(histo, Matchers.notNullValue());
    Histogram.Bucket bucket = histo.getBuckets().get(1);
    assertThat(bucket, Matchers.notNullValue());

    Nested nested = bucket.getAggregations().get("nested");
    assertThat(nested, Matchers.notNullValue());
    assertThat(nested.getName(), equalTo("nested"));
    assertThat(nested.getDocCount(), is(0L));
  }
  @Test
  public void otherNamedBucket() throws Exception {
    SearchResponse response =
        client()
            .prepareSearch("idx")
            .addAggregation(
                filters("tags")
                    .otherBucketKey("foobar")
                    .filter("tag1", termQuery("tag", "tag1"))
                    .filter("tag2", termQuery("tag", "tag2")))
            .execute()
            .actionGet();

    assertSearchResponse(response);

    Filters filters = response.getAggregations().get("tags");
    assertThat(filters, notNullValue());
    assertThat(filters.getName(), equalTo("tags"));

    assertThat(filters.getBuckets().size(), equalTo(3));

    Filters.Bucket bucket = filters.getBucketByKey("tag1");
    assertThat(bucket, Matchers.notNullValue());
    assertThat(bucket.getDocCount(), equalTo((long) numTag1Docs));

    bucket = filters.getBucketByKey("tag2");
    assertThat(bucket, Matchers.notNullValue());
    assertThat(bucket.getDocCount(), equalTo((long) numTag2Docs));

    bucket = filters.getBucketByKey("foobar");
    assertThat(bucket, Matchers.notNullValue());
    assertThat(bucket.getDocCount(), equalTo((long) numOtherDocs));
  }
  @Test
  public void simple_nonKeyed() throws Exception {
    SearchResponse response =
        client()
            .prepareSearch("idx")
            .addAggregation(
                filters("tags").filter(termQuery("tag", "tag1")).filter(termQuery("tag", "tag2")))
            .execute()
            .actionGet();

    assertSearchResponse(response);

    Filters filters = response.getAggregations().get("tags");
    assertThat(filters, notNullValue());
    assertThat(filters.getName(), equalTo("tags"));

    assertThat(filters.getBuckets().size(), equalTo(2));

    Collection<? extends Filters.Bucket> buckets = filters.getBuckets();
    Iterator<? extends Filters.Bucket> itr = buckets.iterator();

    Filters.Bucket bucket = itr.next();
    assertThat(bucket, Matchers.notNullValue());
    assertThat(bucket.getDocCount(), equalTo((long) numTag1Docs));

    bucket = itr.next();
    assertThat(bucket, Matchers.notNullValue());
    assertThat(bucket.getDocCount(), equalTo((long) numTag2Docs));
  }
  @Test
  public void emptyAggregation() throws Exception {
    SearchResponse searchResponse =
        client()
            .prepareSearch("empty_bucket_idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                histogram("histo")
                    .field("value")
                    .interval(1l)
                    .minDocCount(0)
                    .subAggregation(filters("filters").filter("all", matchAllQuery())))
            .execute()
            .actionGet();

    assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
    Histogram histo = searchResponse.getAggregations().get("histo");
    assertThat(histo, Matchers.notNullValue());
    Histogram.Bucket bucket = histo.getBuckets().get(1);
    assertThat(bucket, Matchers.notNullValue());

    Filters filters = bucket.getAggregations().get("filters");
    assertThat(filters, notNullValue());
    Filters.Bucket all = filters.getBucketByKey("all");
    assertThat(all, Matchers.notNullValue());
    assertThat(all.getKeyAsString(), equalTo("all"));
    assertThat(all.getDocCount(), is(0l));
  }
  @Test
  public void adhocIMChat6() throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 1 has received a chat message");

    receiveMessageStatusURL = INVALID;
    String url = (Setup.channelURL[1].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("how are you"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem("adhoc"),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser2Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    Setup.endTest();
  }
  @Test
  public void withSubAggregation() throws Exception {
    SearchResponse response =
        client()
            .prepareSearch("idx")
            .addAggregation(
                filters("tags")
                    .filter("tag1", termQuery("tag", "tag1"))
                    .filter("tag2", termQuery("tag", "tag2"))
                    .subAggregation(avg("avg_value").field("value")))
            .execute()
            .actionGet();

    assertSearchResponse(response);

    Filters filters = response.getAggregations().get("tags");
    assertThat(filters, notNullValue());
    assertThat(filters.getName(), equalTo("tags"));

    assertThat(filters.getBuckets().size(), equalTo(2));
    Object[] propertiesKeys = (Object[]) filters.getProperty("_key");
    Object[] propertiesDocCounts = (Object[]) filters.getProperty("_count");
    Object[] propertiesCounts = (Object[]) filters.getProperty("avg_value.value");

    Filters.Bucket bucket = filters.getBucketByKey("tag1");
    assertThat(bucket, Matchers.notNullValue());
    assertThat(bucket.getDocCount(), equalTo((long) numTag1Docs));
    long sum = 0;
    for (int i = 0; i < numTag1Docs; ++i) {
      sum += i + 1;
    }
    assertThat(bucket.getAggregations().asList().isEmpty(), is(false));
    Avg avgValue = bucket.getAggregations().get("avg_value");
    assertThat(avgValue, notNullValue());
    assertThat(avgValue.getName(), equalTo("avg_value"));
    assertThat(avgValue.getValue(), equalTo((double) sum / numTag1Docs));
    assertThat((String) propertiesKeys[0], equalTo("tag1"));
    assertThat((long) propertiesDocCounts[0], equalTo((long) numTag1Docs));
    assertThat((double) propertiesCounts[0], equalTo((double) sum / numTag1Docs));

    bucket = filters.getBucketByKey("tag2");
    assertThat(bucket, Matchers.notNullValue());
    assertThat(bucket.getDocCount(), equalTo((long) numTag2Docs));
    sum = 0;
    for (int i = numTag1Docs; i < (numTag1Docs + numTag2Docs); ++i) {
      sum += i;
    }
    assertThat(bucket.getAggregations().asList().isEmpty(), is(false));
    avgValue = bucket.getAggregations().get("avg_value");
    assertThat(avgValue, notNullValue());
    assertThat(avgValue.getName(), equalTo("avg_value"));
    assertThat(avgValue.getValue(), equalTo((double) sum / numTag2Docs));
    assertThat((String) propertiesKeys[1], equalTo("tag2"));
    assertThat((long) propertiesDocCounts[1], equalTo((long) numTag2Docs));
    assertThat((double) propertiesCounts[1], equalTo((double) sum / numTag2Docs));
  }
Example #10
0
  @Test
  public void testPostNameDuplicate() throws Exception {
    MockHttpSession session = getSession("ALL");

    Facility facility = new Facility("FacilityA");

    mvc.perform(
            post("/fred/v1/facilities")
                .content(objectMapper.writeValueAsString(facility))
                .session(session)
                .contentType(MediaType.APPLICATION_JSON))
        .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.uuid", Matchers.notNullValue()))
        .andExpect(jsonPath("$.name").value("FacilityA"))
        .andExpect(jsonPath("$.active").value(true))
        .andExpect(jsonPath("$.createdAt", Matchers.notNullValue()))
        .andExpect(jsonPath("$.updatedAt", Matchers.notNullValue()))
        .andExpect(header().string("ETag", Matchers.notNullValue()))
        .andExpect(status().isCreated());

    mvc.perform(
            post("/fred/v1/facilities")
                .content(objectMapper.writeValueAsString(facility))
                .session(session)
                .contentType(MediaType.APPLICATION_JSON))
        .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.uuid", Matchers.notNullValue()))
        .andExpect(jsonPath("$.name").value("FacilityA"))
        .andExpect(jsonPath("$.active").value(true))
        .andExpect(jsonPath("$.createdAt", Matchers.notNullValue()))
        .andExpect(jsonPath("$.updatedAt", Matchers.notNullValue()))
        .andExpect(header().string("ETag", Matchers.notNullValue()))
        .andExpect(status().isCreated());
  }
  @Test
  public void initTest() throws Exception {

    mockMvc
        .perform(
            (post("/test/cache.service"))
                .session(mockHttpSession)
                .param("token", "f20df78d-fc4d-4b90-95f6-d2db0935120c"))
        .andDo(print())
        .andExpect(status().isOk())
        .andExpect(content().contentType("application/json;charset=UTF-8"))
        .andExpect(jsonPath("$.status").value(ResultVo.RESPONSE_CODE_OK))
        .andExpect(jsonPath("$.r").value(Matchers.notNullValue()))
        .andExpect(jsonPath("$.msg").value(Matchers.notNullValue()));
  }
  @Test
  public void sessionIMChatAccept2() {
    Setup.startTest("Checking IM notifications for user 3");
    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList", Matchers.notNullValue())
            .post(url);
    System.out.println(
        "Response = " + notifications3.getStatusCode() + " / " + notifications3.asString());

    /*
    * {"notificationList":[{"messageStatusNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatMessage","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004//messages/1352666437776-470267184"}],
    * "status":"Delivered","messageId":"1352666437776-470267184"}},
    * {"messageStatusNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatMessage","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004//messages/1352666437776-470267184"}],
    * "status":"Displayed","messageId":"1352666437776-470267184"}},
    * {"chatEventNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatSessionInformation","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004/373305033"}],
    * "eventType":"Accepted","sessionId":"373305033"}}]}

    */
    JsonPath jsonData = notifications3.jsonPath();
    sentMessageID = jsonData.getString("notificationList.messageStatusNotification[0].messageId");
    System.out.println("Extracted messageId=" + sentMessageID);
    sendSessionURL = jsonData.getString("notificationList.chatEventNotification.link[0].href[0]");
    System.out.println("Extracted sendSessionURL=" + sendSessionURL);
    sessionID = jsonData.getString("notificationList.chatEventNotification.sessionId[0]");
    System.out.println("Extracted sessionId=" + sessionID);

    Setup.endTest();
  }
Example #13
0
 /**
  * AwsBucket can find and return ockets.
  *
  * @throws Exception If fails
  */
 @Test
 public void findsAndReturnsOckets() throws Exception {
   final Region region = Mockito.mock(Region.class);
   final Bucket bucket = new AwsBucket(region, "example.com");
   final Ocket ocket = bucket.ocket("test");
   MatcherAssert.assertThat(ocket, Matchers.notNullValue());
 }
  @BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0)
  @Test
  public void validateRetieveItemWithLastAccessUpdateTimeDelay() throws Exception {
    // need to ensure we wait 100 ms
    int wait = 100;

    ((DefaultAttributesHandler) repository.getAttributesHandler()).setLastRequestedResolution(wait);
    Thread.sleep(wait);

    AttributeStorage attributeStorageSpy =
        Mockito.spy(repository.getAttributesHandler().getAttributeStorage());
    repository.getAttributesHandler().setAttributeStorage(attributeStorageSpy);

    ResourceStoreRequest resourceRequest = new ResourceStoreRequest(testFilePath);
    resourceRequest.getRequestContext().put(AccessManager.REQUEST_REMOTE_ADDRESS, "127.0.0.1");

    AbstractStorageItem storageItem =
        localRepositoryStorageUnderTest.retrieveItem(repository, resourceRequest);

    MatcherAssert.assertThat(storageItem, Matchers.notNullValue());
    MatcherAssert.assertThat(
        storageItem.getLastRequested(), Matchers.greaterThan(originalLastAccessTime));

    Mockito.verify(attributeStorageSpy, Mockito.times(1))
        .putAttributes(Mockito.<RepositoryItemUid>any(), Mockito.<Attributes>any());
    Mockito.verify(attributeStorageSpy, Mockito.times(1))
        .getAttributes(Mockito.<RepositoryItemUid>any());
  }
  @BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 1)
  @Test
  public void validateRetieveItemWithOutLastAccessUpdateTimeDelay()
      throws LocalStorageException, ItemNotFoundException, IOException {
    // do the test, but make sure the _iterations_ will not get out of the "resolution" span!
    // Note: this test is just broken as is, what guarantees it will finish the cycles in given X
    // millis?
    // Meaning, the assertions + rounds is wrong.
    ((DefaultAttributesHandler) repository.getAttributesHandler())
        .setLastRequestedResolution(30000L);
    AttributeStorage attributeStorageSpy =
        Mockito.spy(repository.getAttributesHandler().getAttributeStorage());
    repository.getAttributesHandler().setAttributeStorage(attributeStorageSpy);

    ResourceStoreRequest resourceRequest = new ResourceStoreRequest(testFilePath);
    resourceRequest.getRequestContext().put(AccessManager.REQUEST_REMOTE_ADDRESS, "127.0.0.1");

    AbstractStorageItem storageItem =
        localRepositoryStorageUnderTest.retrieveItem(repository, resourceRequest);

    MatcherAssert.assertThat(storageItem, Matchers.notNullValue());
    MatcherAssert.assertThat(
        storageItem.getLastRequested(), Matchers.equalTo(originalLastAccessTime));

    Mockito.verify(attributeStorageSpy, Mockito.times(0))
        .putAttributes(Mockito.<RepositoryItemUid>any(), Mockito.<Attributes>any());
    Mockito.verify(attributeStorageSpy, Mockito.times(1))
        .getAttributes(Mockito.<RepositoryItemUid>any());
  }
Example #16
0
  @Test
  public void docCountDerivativeWithGaps() throws Exception {
    SearchResponse searchResponse =
        client()
            .prepareSearch("empty_bucket_idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                histogram("histo")
                    .field(SINGLE_VALUED_FIELD_NAME)
                    .interval(1)
                    .subAggregation(derivative("deriv").setBucketsPaths("_count")))
            .execute()
            .actionGet();

    assertThat(searchResponse.getHits().getTotalHits(), equalTo(numDocsEmptyIdx));

    InternalHistogram<Bucket> deriv = searchResponse.getAggregations().get("histo");
    assertThat(deriv, Matchers.notNullValue());
    assertThat(deriv.getName(), equalTo("histo"));
    List<Bucket> buckets = deriv.getBuckets();
    assertThat(buckets.size(), equalTo(valueCounts_empty.length));

    for (int i = 0; i < valueCounts_empty.length; i++) {
      Histogram.Bucket bucket = buckets.get(i);
      checkBucketKeyAndDocCount("Bucket " + i, bucket, i, valueCounts_empty[i]);
      SimpleValue docCountDeriv = bucket.getAggregations().get("deriv");
      if (firstDerivValueCounts_empty[i] == null) {
        assertThat(docCountDeriv, nullValue());
      } else {
        assertThat(docCountDeriv.value(), equalTo(firstDerivValueCounts_empty[i]));
      }
    }
  }
 /**
  * RtAssignees can iterate over assignees.
  *
  * @throws Exception Exception If some problem inside
  */
 @Test
 public void iteratesAssignees() throws Exception {
   final Iterable<User> users =
       new Smarts<User>(new Bulk<User>(RtAssigneesITCase.repo().assignees().iterate()));
   for (final User user : users) {
     MatcherAssert.assertThat(user.login(), Matchers.notNullValue());
   }
 }
 @Test
 public void deveEscalonarComDoisACemProcessos() {
   for (int i = 2; i <= 100; i++) {
     EscalonadorProcesso fcfs = new FCFS(gerarArrayListDefault(i), 0, 0);
     List<ProcessoVO> resultado = fcfs.resultadoFinal();
     Assert.assertThat(resultado, Matchers.notNullValue());
   }
 }
 /**
  * Set up test fixtures.
  *
  * @throws Exception If some errors occurred.
  */
 @BeforeClass
 public static void setUp() throws Exception {
   final String key = System.getProperty("failsafe.github.key");
   Assume.assumeThat(key, Matchers.notNullValue());
   final Github github = new RtGithub(key);
   repos = github.repos();
   repo = rule.repo(repos);
 }
Example #20
0
 /**
  * Milestone.Smart can fetch due_on property from Milestone.
  *
  * @throws Exception If some problem inside
  */
 @Test
 public final void fetchesDueOn() throws Exception {
   final Milestone milestone = Mockito.mock(Milestone.class);
   Mockito.doReturn(Json.createObjectBuilder().add("due_on", "2011-04-10T20:09:31Z").build())
       .when(milestone)
       .json();
   MatcherAssert.assertThat(new Milestone.Smart(milestone).dueOn(), Matchers.notNullValue());
 }
Example #21
0
 /**
  * Milestone.Smart can fetch state property from Milestone.
  *
  * @throws Exception If some problem inside
  */
 @Test
 public final void fetchesState() throws Exception {
   final Milestone milestone = Mockito.mock(Milestone.class);
   Mockito.doReturn(Json.createObjectBuilder().add("state", "state of the milestone").build())
       .when(milestone)
       .json();
   MatcherAssert.assertThat(new Milestone.Smart(milestone).state(), Matchers.notNullValue());
 }
  @Test
  public void deveRetornarResultadoOrdenadoSimples() {
    final Integer[] BURSTS_SIMPLES = {30, 10, 20, 50, 90};
    final Integer[] ID_SIMPLES = {1, 2, 3, 4, 5};
    final Integer[] TEMPO_ESPERA_PREVISTA_POR_BURST_SIMPLES = {0, 30, 40, 60, 110};
    final Integer[] TEMPO_RESPOSTA_PREVISTA_POR_BURST_SIMPLES = {30, 40, 60, 110, 200};
    final Integer[] TURN_AROUND_PREVISTA_POR_BURST_SIMPLES = {30, 40, 60, 110, 200};

    EscalonadorProcesso fcfs =
        new FCFS(
            gerarArrayListDeProcessos(BURSTS_SIMPLES.length, BURSTS_SIMPLES, null, null), 0, 0);
    List<ProcessoVO> resultado = fcfs.resultadoFinal();

    Assert.assertThat(resultado, Matchers.notNullValue());
    Assert.assertThat(resultado.size(), Matchers.is(BURSTS_SIMPLES.length));

    Iterator<ProcessoVO> resultArrayList = resultado.iterator();
    while (resultArrayList.hasNext()) {
      ProcessoVO proc = resultArrayList.next();
      Assert.assertThat(
          TEMPO_ESPERA_PREVISTA_POR_BURST_SIMPLES, Matchers.hasItemInArray(proc.getEspera()));
      Assert.assertThat(
          TEMPO_RESPOSTA_PREVISTA_POR_BURST_SIMPLES, Matchers.hasItemInArray(proc.getResposta()));
      Assert.assertThat(
          TURN_AROUND_PREVISTA_POR_BURST_SIMPLES, Matchers.hasItemInArray(proc.getTurnAround()));
    }

    List<ProcessoDTO> resultadoGrafico = fcfs.resultadoGraficoFinal();
    Assert.assertThat(resultadoGrafico, Matchers.notNullValue());
    Assert.assertThat(resultadoGrafico.size(), Matchers.is(BURSTS_SIMPLES.length));

    Iterator<ProcessoDTO> resultArrayListGraphic = resultadoGrafico.iterator();
    while (resultArrayListGraphic.hasNext()) {
      ProcessoDTO proc = resultArrayListGraphic.next();
      Assert.assertThat(ID_SIMPLES, Matchers.hasItemInArray(proc.getId()));
    }

    double esperaMedia = fcfs.tempoEsperaMedia();
    double respostaMedia = fcfs.tempoRespostaMedia();
    double turnAroundMedio = fcfs.tempoTurnAroundMedio();
    Assert.assertTrue(turnAroundMedio > 0.0);
    Assert.assertTrue(respostaMedia > 0.0);
    Assert.assertTrue(esperaMedia > 0.0);
    Assert.assertTrue(fcfs.totalProcessos() == BURSTS_SIMPLES.length);
  }
 @Test
 public void testUnmappedModelValue() {
   for (BootProtocol value : BootProtocol.values()) {
     assertThat(
         String.format("%s.%s is not mapped", BootProtocol.class.getName(), value),
         Ipv6BootProtocolMapper.map(value),
         Matchers.notNullValue());
   }
 }
 /**
  * Junit test method for topology nodes Tests if /rest/topo returns status code OK (200) Tests if
  * the returned JSON contains a field "nodes"
  */
 @Test
 public void testTopologyNodes() {
   RestAssured.registerParser("text/plain", Parser.JSON);
   expect()
       .get("/rest/topo")
       .then()
       .statusCode(200)
       .assertThat()
       .body("nodes", Matchers.notNullValue());
 }
Example #25
0
 /** Check that null constrain is enforced for normal get call. */
 @Test
 public void retrievesElementByGetCall() {
   MatcherAssert.assertThat(
       new AwsRules(
               new RegionMocker().with(Mockito.mock(Item.class)).mock(),
               Mockito.mock(SQSClient.class),
               new URN())
           .get("other"),
       Matchers.notNullValue());
 }
Example #26
0
  @Test
  public void testGetFacilityUuid() throws Exception {
    OrganisationUnit organisationUnit = createOrganisationUnit('A');
    manager.save(organisationUnit);

    MockHttpSession session = getSession("ALL");

    mvc.perform(
            get("/fred/v1/facilities/" + organisationUnit.getUuid())
                .session(session)
                .accept(MediaType.APPLICATION_JSON))
        .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.uuid", Matchers.notNullValue()))
        .andExpect(jsonPath("$.name").value("OrgUnitA"))
        .andExpect(jsonPath("$.active").value(true))
        .andExpect(jsonPath("$.createdAt", Matchers.notNullValue()))
        .andExpect(jsonPath("$.updatedAt", Matchers.notNullValue()))
        .andExpect(header().string("ETag", Matchers.notNullValue()))
        .andExpect(status().isOk());
  }
  private void assertSnippet(@NonNull String snippetName, boolean useSandbox) throws Exception {
    WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, snippetName);
    job.setDefinition(
        new CpsFlowDefinition(FileLoaderDSL.getSampleSnippet(snippetName), useSandbox));

    // Run job
    QueueTaskFuture<WorkflowRun> runFuture = job.scheduleBuild2(0, new Action[0]);
    assertThat("build was actually scheduled", runFuture, Matchers.notNullValue());
    WorkflowRun run = runFuture.get();

    j.assertBuildStatus(Result.SUCCESS, run);
  }
  @Test
  public void emptyAggregation() throws Exception {
    prepareCreate("empty_bucket_idx")
        .addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")
        .execute()
        .actionGet();
    List<IndexRequestBuilder> builders = new ArrayList<IndexRequestBuilder>();
    for (int i = 0; i < 2; i++) {
      builders.add(
          client()
              .prepareIndex("empty_bucket_idx", "type", "" + i)
              .setSource(
                  jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, i * 2).endObject()));
    }
    indexRandom(true, builders.toArray(new IndexRequestBuilder[builders.size()]));

    SearchResponse searchResponse =
        client()
            .prepareSearch("empty_bucket_idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                histogram("histo")
                    .field(SINGLE_VALUED_FIELD_NAME)
                    .interval(1l)
                    .minDocCount(0)
                    .subAggregation(terms("terms")))
            .execute()
            .actionGet();

    assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
    Histogram histo = searchResponse.getAggregations().get("histo");
    assertThat(histo, Matchers.notNullValue());
    Histogram.Bucket bucket = histo.getBucketByKey(1l);
    assertThat(bucket, Matchers.notNullValue());

    Terms terms = bucket.getAggregations().get("terms");
    assertThat(terms, Matchers.notNullValue());
    assertThat(terms.getName(), equalTo("terms"));
    assertThat(terms.getBuckets().isEmpty(), is(true));
  }
  @Test
  public void testStandardTestWar() throws Exception {
    PreconfigureStandardTestWar.main(new String[] {});

    WebDescriptor descriptor =
        new WebDescriptor(
            Resource.newResource(
                "./target/test-standard-preconfigured/WEB-INF/quickstart-web.xml"));
    descriptor.setValidating(true);
    descriptor.parse();
    Node node = descriptor.getRoot();
    assertThat(node, Matchers.notNullValue());

    System.setProperty("jetty.home", "target");

    // war file or dir to start
    String war = "target/test-standard-preconfigured";

    // optional jetty context xml file to configure the webapp
    Resource contextXml = Resource.newResource("src/test/resources/test.xml");

    Server server = new Server(0);

    QuickStartWebApp webapp = new QuickStartWebApp();
    webapp.setAutoPreconfigure(true);
    webapp.setWar(war);
    webapp.setContextPath("/");

    // apply context xml file
    if (contextXml != null) {
      // System.err.println("Applying "+contextXml);
      XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
      xmlConfiguration.configure(webapp);
    }

    server.setHandler(webapp);

    server.start();

    URL url =
        new URL(
            "http://127.0.0.1:"
                + server.getBean(NetworkConnector.class).getLocalPort()
                + "/test/dump/info");
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    assertEquals(200, connection.getResponseCode());
    assertThat(
        IO.toString((InputStream) connection.getContent()),
        Matchers.containsString("Dump Servlet"));

    server.stop();
  }
  @BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 1)
  @Test
  public void testRetieveItemWithoutLastAccessUpdate()
      throws LocalStorageException, ItemNotFoundException {
    ResourceStoreRequest resourceRequest = new ResourceStoreRequest(testFilePath);

    AbstractStorageItem storageItem =
        localRepositoryStorageUnderTest.retrieveItem(repository, resourceRequest);

    MatcherAssert.assertThat(storageItem, Matchers.notNullValue());
    MatcherAssert.assertThat(
        storageItem.getLastRequested(), Matchers.equalTo(originalLastAccessTime));
  }