Search in sources :

Example 71 with Sql

use of org.springframework.test.context.jdbc.Sql in project codekvast by crispab.

the class MariadbIntegrationTest method should_getStatus_correctly.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_getStatus_correctly() {
    // given
    Timestamps timestamps = new Timestamps().invoke();
    setSecurityContextCustomerId(1L);
    // when
    GetStatusResponse status = dashboardService.getStatus();
    // then
    assertThat(status.getPricePlan(), is("DEMO"));
    assertThat(status.getCollectionResolutionSeconds(), is(PricePlanDefaults.DEMO.getPublishIntervalSeconds()));
    assertThat(status.getMaxNumberOfAgents(), is(PricePlanDefaults.DEMO.getMaxNumberOfAgents()));
    assertThat(status.getMaxNumberOfMethods(), is(100));
    assertThat(status.getNumAgents(), is(4));
    assertThat(status.getNumLiveAgents(), is(2));
    assertThat(status.getNumLiveEnabledAgents(), is(1));
    assertThat(status.getAgents().get(0), is(AgentDescriptor.builder().agentAlive(true).agentLiveAndEnabled(true).agentVersion("agentVersion1").appName("app1").appVersion("v1").environment("env1").excludePackages("com.foobar.excluded1").hostname("hostname1").id(1L).methodVisibility("public").nextPollExpectedAtMillis(cutMillis(timestamps.plusOneMinute)).nextPublicationExpectedAtMillis(cutMillis(Timestamp.from(timestamps.minusTenMinutes.toInstant().plusSeconds(PricePlanDefaults.DEMO.getPublishIntervalSeconds())))).packages("com.foobar1").pollReceivedAtMillis(cutMillis(timestamps.minusTenMinutes)).publishedAtMillis(cutMillis(timestamps.minusTwoMinutes)).startedAtMillis(cutMillis(timestamps.minusThreeDaysPlus)).tags("tag1=t1,tag2=t2").build()));
    assertThat(status.getNumMethods(), is(10));
    assertThat(status.getCollectedSinceMillis(), is(nullValue()));
    assertThat(status.getCollectedDays(), is(nullValue()));
    assertThat(status.getUsers(), hasSize(2));
}
Also used : GetStatusResponse(io.codekvast.dashboard.dashboard.model.status.GetStatusResponse) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 72 with Sql

use of org.springframework.test.context.jdbc.Sql in project codekvast by crispab.

the class MariadbIntegrationTest method should_accept_valid_getCustomerDataByExternalId_with_pricePlanOverride.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByExternalId_with_pricePlanOverride() {
    CustomerData customerData = customerService.getCustomerDataByExternalId("external-1");
    assertThat(customerData.getCustomerId(), is(1L));
    assertThat(customerData.getCustomerName(), is("Demo"));
    assertThat(customerData.getPricePlan().getName(), is("DEMO"));
    assertThat(customerData.getPricePlan().getOverrideBy(), is("integration test"));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 73 with Sql

use of org.springframework.test.context.jdbc.Sql in project codekvast by crispab.

the class MariadbIntegrationTest method should_accept_valid_getCustomerDataByLicenseKey.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByLicenseKey() {
    CustomerData customerData = customerService.getCustomerDataByLicenseKey("");
    assertThat(customerData.getCustomerId(), is(1L));
    assertThat(customerData.getCustomerName(), is("Demo"));
    assertThat(customerData.getPricePlan().getName(), is("DEMO"));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 74 with Sql

use of org.springframework.test.context.jdbc.Sql in project apollo by ctripcorp.

the class AccessKeyRepositoryTest method testFindFirst500ByDataChangeLastModifiedTimeGreaterThanOrderByDataChangeLastModifiedTime.

@Test
@Sql(scripts = "/sql/accesskey-test.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testFindFirst500ByDataChangeLastModifiedTimeGreaterThanOrderByDataChangeLastModifiedTime() {
    Instant instant = LocalDateTime.of(2019, 12, 19, 13, 44, 20).atZone(ZoneId.systemDefault()).toInstant();
    Date date = Date.from(instant);
    List<AccessKey> accessKeyList = accessKeyRepository.findFirst500ByDataChangeLastModifiedTimeGreaterThanOrderByDataChangeLastModifiedTimeAsc(date);
    assertThat(accessKeyList).hasSize(2);
    assertThat(accessKeyList.get(0).getAppId()).isEqualTo("100004458");
    assertThat(accessKeyList.get(0).getSecret()).isEqualTo("4003c4d7783443dc9870932bebf3b7fe");
    assertThat(accessKeyList.get(1).getAppId()).isEqualTo("100004458");
    assertThat(accessKeyList.get(1).getSecret()).isEqualTo("c715cbc80fc44171b43732c3119c9456");
}
Also used : Instant(java.time.Instant) AccessKey(com.ctrip.framework.apollo.biz.entity.AccessKey) Date(java.util.Date) AbstractIntegrationTest(com.ctrip.framework.apollo.biz.AbstractIntegrationTest) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 75 with Sql

use of org.springframework.test.context.jdbc.Sql in project apollo by ctripcorp.

the class NamespaceBranchServiceTest method testDeleteBranch.

@Test
@Sql(scripts = "/sql/namespace-branch-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testDeleteBranch() {
    GrayReleaseRule rule = instanceGrayReleaseRule();
    namespaceBranchService.updateBranchGrayRules(testApp, testCluster, testNamespace, testBranchName, rule);
    namespaceBranchService.deleteBranch(testApp, testCluster, testNamespace, testBranchName, NamespaceBranchStatus.DELETED, operator);
    Namespace branch = namespaceBranchService.findBranch(testApp, testCluster, testNamespace);
    Assert.assertNull(branch);
    GrayReleaseRule latestRule = namespaceBranchService.findBranchGrayRules(testApp, testCluster, testNamespace, testBranchName);
    Assert.assertNotNull(latestRule);
    Assert.assertEquals(NamespaceBranchStatus.DELETED, latestRule.getBranchStatus());
    Assert.assertEquals("[]", latestRule.getRules());
    Page<ReleaseHistory> releaseHistories = releaseHistoryService.findReleaseHistoriesByNamespace(testApp, testCluster, testNamespace, pageable);
    ReleaseHistory firstReleaseHistory = releaseHistories.getContent().get(1);
    ReleaseHistory secondReleaseHistory = releaseHistories.getContent().get(0);
    Assert.assertEquals(2, releaseHistories.getTotalElements());
    Assert.assertEquals(ReleaseOperation.APPLY_GRAY_RULES, firstReleaseHistory.getOperation());
    Assert.assertEquals(ReleaseOperation.ABANDON_GRAY_RELEASE, secondReleaseHistory.getOperation());
}
Also used : ReleaseHistory(com.ctrip.framework.apollo.biz.entity.ReleaseHistory) GrayReleaseRule(com.ctrip.framework.apollo.biz.entity.GrayReleaseRule) Namespace(com.ctrip.framework.apollo.biz.entity.Namespace) Test(org.junit.Test) AbstractIntegrationTest(com.ctrip.framework.apollo.biz.AbstractIntegrationTest) Sql(org.springframework.test.context.jdbc.Sql)

Aggregations

Sql (org.springframework.test.context.jdbc.Sql)122 Test (org.junit.Test)111 ApolloConfigNotification (com.ctrip.framework.apollo.core.dto.ApolloConfigNotification)26 AbstractIntegrationTest (com.ctrip.framework.apollo.portal.AbstractIntegrationTest)26 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)23 AppDTO (com.ctrip.framework.apollo.common.dto.AppDTO)17 ApolloConfig (com.ctrip.framework.apollo.core.dto.ApolloConfig)17 ApolloNotificationMessages (com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages)17 List (java.util.List)17 AbstractIntegrationTest (com.ctrip.framework.apollo.biz.AbstractIntegrationTest)16 AppNamespace (com.ctrip.framework.apollo.common.entity.AppNamespace)13 ReleaseHistory (com.ctrip.framework.apollo.biz.entity.ReleaseHistory)11 GrayReleaseRule (com.ctrip.framework.apollo.biz.entity.GrayReleaseRule)10 Namespace (com.ctrip.framework.apollo.biz.entity.Namespace)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Release (com.ctrip.framework.apollo.biz.entity.Release)8 AbstractControllerTest (com.ctrip.framework.apollo.adminservice.controller.AbstractControllerTest)6 Favorite (com.ctrip.framework.apollo.portal.entity.po.Favorite)6 CustomerData (io.codekvast.common.customer.CustomerData)6 HttpHeaders (org.springframework.http.HttpHeaders)6