Java 类org.junit.jupiter.api.TestTemplate 实例源码

项目:jiffybox    文件:ModuleMonitoringTest.java   
/**
 * Test for {@link ModuleMonitoring#deleteMonitoringCheck(int)}.
 */
@TestTemplate
void testDeleteMonitoringCheck(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(delete(urlPathEqualTo("/00000000000000000000000000000000/v1.0/monitoring/1234")).willReturn
            (aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/monitoring/testDeleteMonitoringCheck.json")));

    Response<Boolean> response = api.monitoring().deleteMonitoringCheck(1234);
    List<Message> messages = response.getMessages();
    Message message = messages.get(0);

    boolean result = response.getResult();

    assertEquals("Der Monitoring-Check Test(M1234) wird geloescht", message.getMessageText());
    assertEquals(MessageType.SUCCESS, message.getType());

    assertTrue(result);
}
项目:jiffybox    文件:ModuleMonitoringTest.java   
/**
 * Test for {@link ModuleMonitoring#getStatus(int)}.
 */
@TestTemplate
void testGetStatus(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/monitoring/1234/status"))
            .willReturn(aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/monitoring/testGetStatus.json")));

    Response<Map<String, MonitoringStatus>> response = api.monitoring().getStatus(1234);
    List<Message> messages = response.getMessages();
    MonitoringStatus result = response.getResult().get("1234");

    assertTrue(messages.isEmpty());

    assertEquals(0, result.getCode());
    assertEquals("OK - 123.45.67.89: rta 0.313ms, lost 0%", result.getResponse());
}
项目:jiffybox    文件:ModuleMonitoringTest.java   
/**
 * Test for {@link ModuleMonitoring#getStatuses(String)}.
 */
@TestTemplate
void testGetStatuses(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/monitoring/123.45.67.89/status"))
            .willReturn(aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/monitoring/testGetStatuses.json")));

    Response<Map<String, MonitoringStatus>> response = api.monitoring().getStatuses("123.45.67.89");
    List<Message> messages = response.getMessages();
    Map<String, MonitoringStatus> result = response.getResult();

    MonitoringStatus monitoringStatus1 = result.get("1234");
    MonitoringStatus monitoringStatus2 = result.get("5678");

    assertTrue(messages.isEmpty());

    assertEquals(0, monitoringStatus1.getCode());
    assertEquals("OK - 123.45.67.89: rta 0.313ms, lost 0%", monitoringStatus1.getResponse());

    assertEquals(0, monitoringStatus2.getCode());
    assertEquals("HTTP OK: Status line output matched &quot;200&quot; " + "-3827 bytes in 0.003 second response "
            + "time", monitoringStatus2
            .getResponse());
}
项目:jiffybox    文件:ModuleBackupsTest.java   
/**
 * Test for {@link ModuleBackups#createPeriodicalBackups(int, int, int)}.
 */
@TestTemplate
void testCreatePeriodicalBackups(WireMockServer wireMock, JiffyBoxApi api) {
    MappingBuilder builder = post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/backups/12345"));
    StringValuePattern body = equalToJson("{\"dayid\": 0, \"timeid\": 1}", false, false);
    wireMock.stubFor(builder.withRequestBody(body)
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/backups/testCreatePeriodicalBackups.json")));

    Response<BackupConfig> response = api.backups().createPeriodicalBackups(12345, 0, 1);
    List<Message> messages = response.getMessages();
    BackupConfig backup = response.getResult();

    assertTrue(messages.isEmpty());

    assertEquals(0, backup.getDayid());
    assertEquals(1, backup.getTimeid());
}
项目:jiffybox    文件:ModuleBackupsTest.java   
/**
 * Test for {@link ModuleBackups#updatePeriodicalBackups(int, int, int)}.
 */
@TestTemplate
void testUpdatePeriodicalBackups(WireMockServer wireMock, JiffyBoxApi api) {
    MappingBuilder builder = put(urlPathEqualTo("/00000000000000000000000000000000/v1.0/backups/12345"));
    StringValuePattern body = equalToJson("{\"dayid\": 0, \"timeid\": 1}", false, false);
    wireMock.stubFor(builder.withRequestBody(body)
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/backups/testUpdatePeriodicalBackups.json")));

    Response<BackupConfig> response = api.backups().updatePeriodicalBackups(12345, 0, 1);
    List<Message> messages = response.getMessages();
    BackupConfig backup = response.getResult();

    assertTrue(messages.isEmpty());

    assertEquals(0, backup.getDayid());
    assertEquals(1, backup.getTimeid());
}
项目:jiffybox    文件:ModuleBackupsTest.java   
/**
 * Test for {@link ModuleBackups#deletePeriodicalBackups(int)}.
 */
@TestTemplate
void testDeletePeriodicalBackups(WireMockServer wireMock, JiffyBoxApi api) {
    MappingBuilder builder = delete(urlPathEqualTo("/00000000000000000000000000000000/v1.0/backups/12345"));
    wireMock.stubFor(builder.willReturn(aResponse().withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/backups/testDeletePeriodicalBackups.json")));

    Response<Boolean> response = api.backups().deletePeriodicalBackups(12345);
    List<Message> messages = response.getMessages();
    Boolean result = response.getResult();

    assertTrue(messages.isEmpty());

    assertTrue(result);
}
项目:jiffybox    文件:ModuleBackupsTest.java   
/**
 * Test for {@link ModuleBackups#createManualBackup(int)}.
 */
@TestTemplate
void testCreateManualBackup(WireMockServer wireMock, JiffyBoxApi api) {
    MappingBuilder builder = post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/backups/12345/manual"));
    StringValuePattern body = equalToJson("{}", false, false);
    wireMock.stubFor(builder.withRequestBody(body)
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/backups/testCreateManualBackups.json")));

    Response<Boolean> response = api.backups().createManualBackup(12345);
    List<Message> messages = response.getMessages();
    Boolean result = response.getResult();

    assertTrue(messages.isEmpty());

    assertTrue(result);
}
项目:jiffybox    文件:ModuleBackupsTest.java   
/**
 * Test for {@link ModuleBackups#deleteBackup(int, String, String)}.
 */
@TestTemplate
void testDeleteBackup(WireMockServer wireMock, JiffyBoxApi api) {
    MappingBuilder builder = delete(urlPathEqualTo
            ("/00000000000000000000000000000000/v1.0/backups/12345/daily/12345ACDEF"));
    wireMock.stubFor(builder.willReturn(aResponse().withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/backups/testDeleteBackup.json")));

    Response<Boolean> response = api.backups().deleteBackup(12345, "daily", "12345ACDEF");
    List<Message> messages = response.getMessages();
    Boolean result = response.getResult();

    assertTrue(messages.isEmpty());

    assertTrue(result);
}
项目:jiffybox    文件:ModuleBackupsTest.java   
/**
 * Test for {@link ModuleBackups#restoreBackup(int, String, String)}.
 */
@TestTemplate
void testRestoreBackup(WireMockServer wireMock, JiffyBoxApi api) {
    MappingBuilder builder = post(urlPathEqualTo
            ("/00000000000000000000000000000000/v1.0/backups/12345/daily/12345ACDEF"));
    StringValuePattern body = equalToJson("{}", false, false);
    wireMock.stubFor(builder.withRequestBody(body)
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/backups/testRestoreBackup.json")));

    Response<Boolean> response = api.backups().restoreBackup(12345, "daily", "12345ACDEF");
    List<Message> messages = response.getMessages();
    Boolean result = response.getResult();

    assertTrue(messages.isEmpty());

    assertTrue(result);
}
项目:jiffybox    文件:ModulePlansTest.java   
/**
 * Test for {@link ModulePlans#getPlan(int)}.
 */
@TestTemplate
void testGetPlan(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/plans/45")).willReturn(aResponse
            ().withHeaders(WireMockHelper
            .headers()).withStatus(200).withBodyFile("modules/plans/testGetPlan.json")));

    Response<Plan> response = api.plans().getPlan(45);
    List<Message> messages = response.getMessages();
    Plan result = response.getResult();

    assertTrue(messages.isEmpty());

    assertEquals(2, result.getCpus());
    assertEquals(204800, result.getDiskSizeInMB());
    assertEquals(45, result.getId());
    assertEquals("CloudLevel 2", result.getName());
    assertEquals(19.99, result.getPriceCap(), 0.001);
    assertEquals(0.03, result.getPricePerHour(), 0.001);
    assertEquals(0.01, result.getPricePerHourFrozen(), 0.001);
    assertEquals(4096, result.getRamInMB());
}
项目:jiffybox    文件:ModulePlansTest.java   
/**
 * Test for {@link ModulePlans#getPlan(String)}.
 */
@TestTemplate
void testGetPlan1(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/plans/CloudLevel%202"))
            .willReturn(aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/plans/testGetPlan1.json")));

    Response<Plan> response = api.plans().getPlan("CloudLevel 2");
    List<Message> messages = response.getMessages();
    Plan result = response.getResult();

    assertTrue(messages.isEmpty());

    assertEquals(2, result.getCpus());
    assertEquals(204800, result.getDiskSizeInMB());
    assertEquals(45, result.getId());
    assertEquals("CloudLevel 2", result.getName());
    assertEquals(19.99, result.getPriceCap(), 0.001);
    assertEquals(0.03, result.getPricePerHour(), 0.001);
    assertEquals(0.01, result.getPricePerHourFrozen(), 0.001);
    assertEquals(4096, result.getRamInMB());
}
项目:jiffybox    文件:ModuleContactGroupsTest.java   
/**
 * Test for {@link ModuleContactGroups#deleteContactGroup(int)}.
 */
@TestTemplate
void testDeleteContactGroup(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(delete(urlPathEqualTo("/00000000000000000000000000000000/v1.0/contactGroups/123"))
            .willReturn(aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/contactGroups/testDeleteContactGroup.json")));

    Response<Boolean> response = api.contactGroups().deleteContactGroup(123);
    List<Message> messages = response.getMessages();
    Boolean result = response.getResult();

    assertTrue(messages.isEmpty());

    assertTrue(result);
}
项目:jiffybox    文件:ModuleJiffyBoxesTest.java   
/**
 * Test for {@link ModuleJiffyBoxes#deleteJiffyBox(int)}.
 */
@TestTemplate
void testDeleteJiffyBox(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(delete(urlPathEqualTo("/00000000000000000000000000000000/v1.0/jiffyBoxes/12345")).willReturn
            (aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/jiffyBoxes/testDeleteJiffyBox.json")));

    Response<Boolean> response = api.jiffyBoxes().deleteJiffyBox(12345);
    List<Message> messages = response.getMessages();

    assertTrue(messages.isEmpty());

    assertTrue(response.getResult());
}
项目:jiffybox    文件:ModuleJiffyBoxesTest.java   
/**
 * Test for {@link ModuleJiffyBoxes#duplicateJiffyBox(int, String, int, ObjectNode)}.
 */
@TestTemplate
void testDuplicateJiffyBoxWithMetadata1(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/jiffyBoxes/12345"))
            .withRequestBody(equalToJson("{\"name\": \"Test\", \"planid\": 10, \"metadata\":{\"createdBy\": " +
                    "\"The" + " " + "JiffyBoxTeam\", \"usedBy\": [\"Me\", \"You\", \"Everyone\"], " +
                    "\"freeForAll\":false}}"))
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/jiffyBoxes/testDuplicateJiffyBoxWithMetadata1.json")));

    ObjectNode metadata = Build.metadata().put("createdBy", "The JiffyBoxTeam");
    metadata.putArray("usedBy").add("Me").add("You").add("Everyone");
    metadata.put("freeForAll", false);

    Response<JiffyBox> response = api.jiffyBoxes().duplicateJiffyBox(12345, "Test", 10, metadata);
    testDuplicateJiffyBoxResponse(response);
}
项目:jiffybox    文件:ModuleJiffyBoxesTest.java   
/**
 * Test for {@link ModuleJiffyBoxes#duplicateJiffyBox(int, String, String, ObjectNode)}.
 */
@TestTemplate
void testDuplicateJiffyBoxWithMetadata2(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/jiffyBoxes/12345"))
            .withRequestBody(equalToJson("{\"name\": \"Test\", \"planid\": \"CloudLevel 1\", " +
                    "\"metadata\":{\"createdBy\": " + "\"The JiffyBoxTeam\", \"usedBy\": [\"Me\", \"You\", " +
                    "\"Everyone\"], " + "\"freeForAll\":false}}"))
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/jiffyBoxes/testDuplicateJiffyBoxWithMetadata2.json")));

    ObjectNode metadata = Build.metadata().put("createdBy", "The JiffyBoxTeam");
    metadata.putArray("usedBy").add("Me").add("You").add("Everyone");
    metadata.put("freeForAll", false);

    Response<JiffyBox> response = api.jiffyBoxes().duplicateJiffyBox(12345, "Test", "CloudLevel 1", metadata);
    testDuplicateJiffyBoxResponse(response);
}
项目:jiffybox    文件:ModuleDocTest.java   
/**
 * Test for {@link ModuleDoc#getDocs()}.
 */
@TestTemplate
void testGetDocs(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/doc")).willReturn(aResponse()
            .withHeaders(WireMockHelper
            .headers()).withStatus(200).withBodyFile("modules/doc/testGetDocs.json")));

    Response<Map<String, String>> response = api.doc().getDocs();
    List<Message> messages = response.getMessages();
    assertTrue(messages.isEmpty());

    Map<String, String> docs = response.getResult();
    assertEquals("Modul zur Monitoring-Verwaltung", docs.get("Monitoring"));
    assertEquals("Modul zum Auflisten und Manipulieren von JiffyBoxen", docs.get("JiffyBoxes"));
    assertEquals("Dokumentationsmodul", docs.get("Doc"));
    assertEquals("Modul zum Auflisten von installierbaren Linux-Distributionen", docs.get("Distributions"));
    assertEquals("Modul zum Auflisten und ändern von IP-Adressen", docs.get("Ips"));
    assertEquals("Modul zum Auflisten von JiffyBox-Tarifen", docs.get("Plans"));
    assertEquals("Modul zum Auflisten und Beantragen von Backups", docs.get("Backups"));
    assertEquals("Modul zur Verwaltung von Kontaktgruppen", docs.get("ContactGroups"));
}
项目:jiffybox    文件:ModuleDistributionsTest.java   
/**
 * Test for {@link ModuleDistributions#getDistribution(String)}.
 */
@TestTemplate
void testGetDistribution(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/distributions/centos_5_4_64bit"))
            .willReturn(aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/distributions/testGetDistribution.json")));

    Response<Distribution> response = api.distributions().getDistribution("centos_5_4_64bit");
    List<Message> messages = response.getMessages();
    Distribution distribution = response.getResult();

    assertTrue(messages.isEmpty());

    assertEquals(1024, distribution.getMinDiskSizeMB());
    assertEquals("xen-current-x86_64", distribution.getDefaultKernel());
    assertEquals("CentOS 5.4 64-Bit", distribution.getName());
    assertEquals("ro", distribution.getRootdiskMode());
}
项目:selenium-jupiter    文件:SeleniumJupiter.java   
private static String getSurefireOutputFolder(Method testMethod,
        Class<?> testInstance) {
    Annotation[] annotations = testMethod.getAnnotations();
    StringBuilder stringBuilder = new StringBuilder(
            "./target/surefire-reports/");

    boolean isTestTemplate = stream(annotations)
            .map(Annotation::annotationType)
            .anyMatch(a -> a == TestTemplate.class);
    log.trace("Is test template? {}", isTestTemplate);

    if (isTestTemplate) {
        stringBuilder.append(testMethod.getName());
        stringBuilder.append("(");

        Class<?>[] parameterTypes = testMethod.getParameterTypes();
        for (int i = 0; i < parameterTypes.length; i++) {
            if (i != 0) {
                stringBuilder.append(", ");
            }
            stringBuilder.append(parameterTypes[i].getSimpleName());
        }
        stringBuilder.append(")/");

    } else {
        stringBuilder.append(testInstance.getName());
    }
    return stringBuilder.toString();
}
项目:selenium-jupiter    文件:TemplateTwoBrowsersTest.java   
@TestTemplate
void templateTest(WebDriver driver1, WebDriver driver2) {
    driver1.get("https://bonigarcia.github.io/selenium-jupiter/");
    driver2.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver1.getTitle(),
            containsString("A JUnit 5 extension for Selenium WebDriver"));
    assertThat(driver2.getTitle(),
            containsString("A JUnit 5 extension for Selenium WebDriver"));
}
项目:jiffybox    文件:ModuleMonitoringTest.java   
/**
 * Test for {@link ModuleMonitoring#getMonitoringChecks()}.
 */
@TestTemplate
void testGetMonitoringChecks(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/monitoring")).willReturn(aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/monitoring/testGetMonitoringChecks.json")));

    Response<Map<String, MonitoringCheck>> response = api.monitoring().getMonitoringChecks();
    List<Message> messages = response.getMessages();
    Map<String, MonitoringCheck> result = response.getResult();
    MonitoringCheck monitoringCheck = result.get("911");

    List<ContactGroup> contactGroups = monitoringCheck.getContactgroups();
    ContactGroup contactGroup = contactGroups.get(0);

    assertTrue(messages.isEmpty());

    assertEquals(300, monitoringCheck.getCheckInterval());
    assertEquals(MonitoringCheckType.HTTP, monitoringCheck.getCheckType());
    assertEquals("example.com", monitoringCheck.getDomainname());
    assertEquals(1234, monitoringCheck.getId());
    assertEquals("188.93.14.165", monitoringCheck.getIp());
    assertEquals(4849, monitoringCheck.getJiffyBox());
    assertEquals("test", monitoringCheck.getName());
    assertEquals("", monitoringCheck.getPassword());
    assertEquals("/index.php", monitoringCheck.getPath());
    assertEquals(80, monitoringCheck.getPort());
    assertEquals(3600, monitoringCheck.getReminderInterval());
    assertEquals(3, monitoringCheck.getRetryTolerance());
    assertEquals(MonitoringCheckStatus.STATUS_READY, monitoringCheck.getStatus());
    assertEquals("", monitoringCheck.getUsername());

    assertTrue(contactGroup.getContacts().isEmpty());
    assertEquals(123, contactGroup.getId());
    assertEquals("TestGruppe", contactGroup.getName());
    assertNull(contactGroup.getStatus());
}
项目:jiffybox    文件:ModuleMonitoringTest.java   
/**
 * Test for {@link ModuleMonitoring#getMonitoringCheck(int)}.
 */
@TestTemplate
void testGetMonitoringCheck(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/monitoring/1234")).willReturn
            (aResponse()
            .withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/monitoring/testGetMonitoringCheck.json")));

    Response<MonitoringCheck> response = api.monitoring().getMonitoringCheck(1234);
    List<Message> messages = response.getMessages();
    MonitoringCheck result = response.getResult();

    List<ContactGroup> contactGroups = result.getContactgroups();
    ContactGroup contactGroup = contactGroups.get(0);

    assertTrue(messages.isEmpty());

    assertEquals(300, result.getCheckInterval());
    assertEquals(MonitoringCheckType.HTTP, result.getCheckType());
    assertEquals("example.com", result.getDomainname());
    assertEquals(1234, result.getId());
    assertEquals("188.93.14.211", result.getIp());
    assertEquals(4849, result.getJiffyBox());
    assertEquals("test", result.getName());
    assertEquals("", result.getPassword());
    assertEquals("/index.php", result.getPath());
    assertEquals(80, result.getPort());
    assertEquals(3600, result.getReminderInterval());
    assertEquals(3, result.getRetryTolerance());
    assertEquals(MonitoringCheckStatus.STATUS_READY, result.getStatus());
    assertEquals("", result.getUsername());

    assertTrue(contactGroup.getContacts().isEmpty());
    assertEquals(123, contactGroup.getId());
    assertEquals("TestGruppe", contactGroup.getName());
    assertNull(contactGroup.getStatus());
}
项目:jiffybox    文件:ModuleMonitoringTest.java   
/**
 * Test for {@link ModuleMonitoring#createMonitoringCheck(MonitoringCheckBuilder)}.
 */
@TestTemplate
void testCreateMonitoringCheck(WireMockServer wireMock, JiffyBoxApi api) {
    String body = "{\"name\": \"Test\", \"ip\": \"188.93.14.211\", \"checkType\":\"http\", \"port\": 80, " +
            "\"path\": \"/index.php\", \"domainname\": \"example.com\"}";
    wireMock.stubFor(post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/monitoring")).withRequestBody
            (equalToJson(body, false, false))
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/monitoring/testCreateMonitoringCheck.json")));

    MonitoringCheckBuilder data = Build.monitoringCheck("Test", "188.93.14.211", 80)
            .http("example.com", "/index.php");

    Response<MonitoringCheck> response = api.monitoring().createMonitoringCheck(data);
    List<Message> messages = response.getMessages();
    MonitoringCheck result = response.getResult();

    assertTrue(messages.isEmpty());

    assertEquals(300, result.getCheckInterval());
    assertEquals(MonitoringCheckType.HTTP, result.getCheckType());
    assertTrue(result.getContactgroups().isEmpty());
    assertEquals("example.com", result.getDomainname());
    assertEquals(1234, result.getId());
    assertEquals("188.93.14.211", result.getIp());
    assertEquals(4849, result.getJiffyBox());
    assertEquals("Test", result.getName());
    assertNull(result.getPassword());
    assertEquals("/index.php", result.getPath());
    assertEquals(80, result.getPort());
    assertEquals(3600, result.getReminderInterval());
    assertEquals(3, result.getRetryTolerance());
    assertEquals(MonitoringCheckStatus.STATUS_CREATING, result.getStatus());
    assertNull(result.getUsername());
}
项目:jiffybox    文件:ModuleMonitoringTest.java   
/**
 * Test for {@link ModuleMonitoring#duplicateMonitoringCheck(int, MonitoringCheckBuilder)}.
 */
@TestTemplate
void testDuplicateMonitoringCheck(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/monitoring/1234"))
            .withRequestBody(equalToJson("{\"name\": \"Kopie von Test\", \"ip\": \"188.93.14.212\"}", false, false))
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/monitoring/testDuplicateMonitoringCheck.json")));

    MonitoringCheckBuilder data = Build.monitoringCheck("Kopie von Test", "188.93.14.212", null).preserveType();

    Response<MonitoringCheck> response = api.monitoring().duplicateMonitoringCheck(1234, data);
    List<Message> messages = response.getMessages();
    MonitoringCheck result = response.getResult();

    assertTrue(messages.isEmpty());

    assertEquals(300, result.getCheckInterval());
    assertEquals(MonitoringCheckType.HTTP, result.getCheckType());
    assertTrue(result.getContactgroups().isEmpty());
    assertEquals("example.com", result.getDomainname());
    assertEquals(1235, result.getId());
    assertEquals("188.93.14.212", result.getIp());
    assertEquals(4849, result.getJiffyBox());
    assertEquals("Kopie von Test", result.getName());
    assertNull(result.getPassword());
    assertEquals("/index.php", result.getPath());
    assertEquals(80, result.getPort());
    assertEquals(3600, result.getReminderInterval());
    assertEquals(3, result.getRetryTolerance());
    assertEquals(MonitoringCheckStatus.STATUS_CREATING, result.getStatus());
    assertNull(result.getUsername());
}
项目:jiffybox    文件:ModuleBackupsTest.java   
/**
 * Test for {@link ModuleBackups#getBackup(int)}.
 */
@TestTemplate
void testGetBackup(WireMockServer wireMock, JiffyBoxApi api) {
    MappingBuilder builder = get(urlPathEqualTo("/00000000000000000000000000000000/v1.0/backups/12345"));
    wireMock.stubFor(builder.willReturn(aResponse().withHeaders(WireMockHelper.headers())
            .withStatus(200)
            .withBodyFile("modules/backups/testGetBackup.json")));

    Response<Backup> response = api.backups().getBackup(12345);
    List<Message> messages = response.getMessages();
    Backup backup = response.getResult();
    BackupEntry daily = backup.getDaily();
    BackupEntry weekly = backup.getWeekly();
    BackupEntry biweekly = backup.getBiweekly();

    assertTrue(messages.isEmpty());

    assertEquals(1, backup.getDay());
    assertEquals(1, backup.getTime());

    assertEquals(1234567890, daily.getCreated());
    assertEquals("1234567890abcdef1234567890abcdef", daily.getId());
    assertEquals(1234567890, weekly.getCreated());
    assertEquals("234567890abcdef1234567890abcdef1", weekly.getId());
    assertEquals(1234567890, biweekly.getCreated());
    assertEquals("34567890abcdef1234567890abcdef12", biweekly.getId());

    assertNull(backup.getManual());
}
项目:jiffybox    文件:ModuleIpsTest.java   
/**
 * Test for {@link ModuleIps#moveIPAddress(int, int, int)}.
 */
@TestTemplate
void testMoveIPAddress(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(put(urlPathEqualTo("/00000000000000000000000000000000/v1.0/ips/12345/8465/move"))
            .withRequestBody(equalToJson("{\"targetid\": 4321}", false, false))
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/ips/testMoveIPAddress.json")));

    Response<Boolean> response = api.ips().moveIPAddress(12345, 8465, 4321);
    List<Message> messages = response.getMessages();

    assertTrue(messages.isEmpty());
    assertTrue(response.getResult());
}
项目:jiffybox    文件:ModuleJiffyBoxesTest.java   
/**
 * Test for {@link ModuleJiffyBoxes#duplicateJiffyBox(int, String, int)}.
 */
@TestTemplate
void testDuplicateJiffyBox1(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/jiffyBoxes/12345"))
            .withRequestBody(equalToJson("{\"name\": \"Test\", \"planid\": 10}"))
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/jiffyBoxes/testDuplicateJiffyBox1.json")));

    Response<JiffyBox> response = api.jiffyBoxes().duplicateJiffyBox(12345, "Test", 10);
    testDuplicateJiffyBoxResponse(response);
}
项目:jiffybox    文件:ModuleJiffyBoxesTest.java   
/**
 * Test for {@link ModuleJiffyBoxes#duplicateJiffyBox(int, String, String)}.
 */
@TestTemplate
void testDuplicateJiffyBox2(WireMockServer wireMock, JiffyBoxApi api) {
    wireMock.stubFor(post(urlPathEqualTo("/00000000000000000000000000000000/v1.0/jiffyBoxes/12345"))
            .withRequestBody(equalToJson("{\"name\": \"Test\", \"planid\": \"CloudLevel 1\"}"))
            .willReturn(aResponse().withHeaders(WireMockHelper.headers())
                    .withStatus(200)
                    .withBodyFile("modules/jiffyBoxes/testDuplicateJiffyBox2.json")));

    Response<JiffyBox> response = api.jiffyBoxes().duplicateJiffyBox(12345, "Test", "CloudLevel 1");
    testDuplicateJiffyBoxResponse(response);
}
项目:random-beans    文件:NumberRandomizersTest.java   
@TestTemplate
@UseDataProvider("generateRandomizers")
public void generatedNumberShouldNotBeNull(Randomizer<?> randomizer) {
    // when
    Object randomNumber = randomizer.getRandomValue();

    then(randomNumber).isNotNull();
}
项目:random-beans    文件:NumberRandomizersTest.java   
@TestTemplate
@UseDataProvider("generateSeededRandomizersAndTheirExpectedValues")
public void shouldGenerateTheSameValueForTheSameSeed(Randomizer<?> randomizer, Object expected) {
    //when
    Object actual = randomizer.getRandomValue();

    then(actual).isEqualTo(expected);
}
项目:random-beans    文件:TimeRandomizersTest.java   
@TestTemplate
@UseDataProvider("generateRandomizers")
public void generatedTimeShouldNotBeNull(Randomizer<?> randomizer) {
    // when
    Object randomNumber = randomizer.getRandomValue();

    then(randomNumber).isNotNull();
}
项目:random-beans    文件:TimeRandomizersTest.java   
@TestTemplate
@UseDataProvider("generateSeededRandomizersAndTheirExpectedValues")
public void shouldGenerateTheSameValueForTheSameSeed(Randomizer<?> randomizer, Object expected) {
    //when
    Object actual = randomizer.getRandomValue();

    then(actual).isEqualTo(expected);
}
项目:random-beans    文件:CollectionRandomizersTest.java   
@TestTemplate
@UseDataProvider("generateCollectionRandomizers")
public <T> void generatedCollectionShouldNotBeNull(Randomizer<Collection<T>> collectionRandomizer) {
    // when
    Collection<T> randomCollection = collectionRandomizer.getRandomValue();

    then(randomCollection).isNotNull();
}
项目:random-beans    文件:CollectionRandomizersTest.java   
@TestTemplate
@UseDataProvider("generateCollectionRandomizersWithSpecificSize")
public <T> void generatedCollectionSizeShouldBeEqualToTheSpecifiedSize(Randomizer<Collection<T>> collectionRandomizer) {
    // when
    Collection<T> randomCollection = collectionRandomizer.getRandomValue();

    then(randomCollection).hasSize(collectionSize);
}