Search in sources :

Example 6 with Sql

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

the class MariadbIntegrationTest method should_getConfig_for_disabled_agent.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_getConfig_for_disabled_agent() {
    // given
    new Timestamps().invoke();
    // when
    GetConfigResponse1 response = agentService.getConfig(GetConfigRequest1.sample().toBuilder().jvmUuid("uuid2").licenseKey("").startedAtMillis(Instant.now().minus(2, HOURS).toEpochMilli()).build());
    // then
    assertConfigPollResponse(response, "enabled=false");
    assertAgentEnabled("uuid1", TRUE);
    assertAgentEnabled("uuid2", FALSE);
    assertAgentEnabled("uuid3", FALSE);
    assertAgentEnabled("uuid4", FALSE);
}
Also used : GetConfigResponse1(io.codekvast.javaagent.model.v1.rest.GetConfigResponse1) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 7 with Sql

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

the class MariadbIntegrationTest method should_accept_valid_getCustomerDataByExternalId_without_pricePlanOverride.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByExternalId_without_pricePlanOverride() {
    CustomerData customerData = customerService.getCustomerDataByExternalId("external-2");
    assertThat(customerData.getCustomerId(), is(2L));
    assertThat(customerData.getPricePlan().getOverrideBy(), nullValue());
    assertThat(customerData.isTrialPeriodExpired(Instant.now()), is(false));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 8 with Sql

use of org.springframework.test.context.jdbc.Sql in project commons-dao by reportportal.

the class AttachmentCommonDataStoreServiceTest method AttachFileToExistingLogTest.

@Test
@Sql("/db/fill/data-store/data-store-fill.sql")
void AttachFileToExistingLogTest() {
    String fileID = "fileID";
    String thumbnailID = "thumbnailID";
    String contentType = "content-type";
    long fileSize = 1024;
    final LocalDateTime creationDate = LocalDateTime.of(2020, Month.JANUARY, 1, 1, 1);
    BinaryDataMetaInfo binaryDataMetaInfo = new BinaryDataMetaInfo();
    binaryDataMetaInfo.setFileId(fileID);
    binaryDataMetaInfo.setThumbnailFileId(thumbnailID);
    binaryDataMetaInfo.setContentType(contentType);
    binaryDataMetaInfo.setFileSize(fileSize);
    Long projectId = 1L;
    Long itemId = 1L;
    AttachmentMetaInfo attachmentMetaInfo = AttachmentMetaInfo.builder().withProjectId(projectId).withLaunchId(1L).withItemId(itemId).withLogId(1L).withCreationDate(creationDate).build();
    attachmentBinaryDataService.attachToLog(binaryDataMetaInfo, attachmentMetaInfo);
    Optional<Attachment> attachment = attachmentRepository.findByFileId(fileID);
    assertTrue(attachment.isPresent());
    assertEquals(projectId, attachment.get().getProjectId());
    assertEquals(itemId, attachment.get().getItemId());
    assertEquals(fileID, attachment.get().getFileId());
    assertEquals(thumbnailID, attachment.get().getThumbnailId());
    assertEquals(contentType, attachment.get().getContentType());
    assertEquals(fileSize, attachment.get().getFileSize());
    assertEquals(creationDate, attachment.get().getCreationDate());
}
Also used : LocalDateTime(java.time.LocalDateTime) Attachment(com.epam.ta.reportportal.entity.attachment.Attachment) BinaryDataMetaInfo(com.epam.ta.reportportal.commons.BinaryDataMetaInfo) AttachmentMetaInfo(com.epam.ta.reportportal.entity.attachment.AttachmentMetaInfo) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 9 with Sql

use of org.springframework.test.context.jdbc.Sql in project commons-dao by reportportal.

the class LogRepositoryTest method findLogMessagesByItemIdAndLogLevelNestedTest.

@Sql("/db/fill/item/items-with-nested-steps.sql")
@Test
void findLogMessagesByItemIdAndLogLevelNestedTest() {
    TestItem testItem = testItemRepository.findById(132L).get();
    List<String> messagesByItemIdAndLevelGte = logRepository.findMessagesByLaunchIdAndItemIdAndPathAndLevelGte(testItem.getLaunchId(), testItem.getItemId(), testItem.getPath(), LogLevel.ERROR.toInt());
    assertTrue(CollectionUtils.isNotEmpty(messagesByItemIdAndLevelGte));
    assertEquals(1, messagesByItemIdAndLevelGte.size());
    assertEquals("java.lang.NullPointerException: Oops\n" + "\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" + "\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" + "\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" + "\tat java.base/java.lang.reflect.Method.invoke(Method.java:566)\n", messagesByItemIdAndLevelGte.get(0));
}
Also used : TestItem(com.epam.ta.reportportal.entity.item.TestItem) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 10 with Sql

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

the class NamespaceBranchServiceTest method testFindBranch.

@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 testFindBranch() {
    Namespace branch = namespaceBranchService.findBranch(testApp, testCluster, testNamespace);
    Assert.assertNotNull(branch);
    Assert.assertEquals(testBranchName, branch.getClusterName());
}
Also used : 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