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));
}
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"));
}
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"));
}
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");
}
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());
}
Aggregations