Search in sources :

Example 21 with MetadataVersion

use of org.hisp.dhis.metadata.version.MetadataVersion in project dhis2-core by dhis2.

the class MetadataSyncPostProcessorTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    dataVersion = new MetadataVersion();
    dataVersion.setType(VersionType.BEST_EFFORT);
    dataVersion.setName("testVersion");
    dataVersion.setCreated(new Date());
    dataVersion.setHashCode("samplehashcode");
    metadataSyncSummary = new MetadataSyncSummary();
}
Also used : MetadataVersion(org.hisp.dhis.metadata.version.MetadataVersion) Date(java.util.Date) Before(org.junit.Before)

Example 22 with MetadataVersion

use of org.hisp.dhis.metadata.version.MetadataVersion in project dhis2-core by dhis2.

the class MetadataVersionDelegateTest method testShouldGetRemoteMetadataVersionWithStatusOk.

@Test
public void testShouldGetRemoteMetadataVersionWithStatusOk() throws Exception {
    AvailabilityStatus availabilityStatus = new AvailabilityStatus(true, "testMessage", null);
    DhisHttpResponse dhisHttpResponse = new DhisHttpResponse(httpResponse, response, HttpStatus.OK.value());
    when(metadataSystemSettingService.getVersionDetailsUrl("testVersion")).thenReturn(versionUrl);
    when(synchronizationManager.isRemoteServerAvailable()).thenReturn(availabilityStatus);
    PowerMockito.when(HttpUtils.httpGET(versionUrl, true, username, password, null, VERSION_TIMEOUT, true)).thenReturn(dhisHttpResponse);
    when(renderService.fromJson(response, MetadataVersion.class)).thenReturn(metadataVersion);
    MetadataVersion remoteMetadataVersion = metadataVersionDelegate.getRemoteMetadataVersion("testVersion");
    assertEquals(metadataVersion.getType(), remoteMetadataVersion.getType());
    assertEquals(metadataVersion.getHashCode(), remoteMetadataVersion.getHashCode());
    assertEquals(metadataVersion.getName(), remoteMetadataVersion.getName());
    assertEquals(metadataVersion, remoteMetadataVersion);
}
Also used : MetadataVersion(org.hisp.dhis.metadata.version.MetadataVersion) DhisHttpResponse(org.hisp.dhis.system.util.DhisHttpResponse) AvailabilityStatus(org.hisp.dhis.dxf2.synch.AvailabilityStatus) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) IntegrationTest(org.hisp.dhis.IntegrationTest) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 23 with MetadataVersion

use of org.hisp.dhis.metadata.version.MetadataVersion in project dhis2-core by dhis2.

the class HibernateMetadataVersionStoreTest method testGetVersionByName.

@Test
public void testGetVersionByName() throws Exception {
    MetadataVersion metadataVersion = new MetadataVersion("version1", VersionType.ATOMIC);
    metadataVersion.setHashCode("12345");
    metadataVersionStore.save(metadataVersion);
    assertEquals(metadataVersion, metadataVersionStore.getVersionByName("version1"));
    assertNull(metadataVersionStore.getVersionByName("non_existing"));
    metadataVersionStore.delete(metadataVersion);
}
Also used : MetadataVersion(org.hisp.dhis.metadata.version.MetadataVersion) DhisSpringTest(org.hisp.dhis.DhisSpringTest) Test(org.junit.Test)

Example 24 with MetadataVersion

use of org.hisp.dhis.metadata.version.MetadataVersion in project dhis2-core by dhis2.

the class HibernateMetadataVersionStoreTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    MetadataVersion metadataVersion = new MetadataVersion("version1", VersionType.ATOMIC);
    metadataVersion.setHashCode("12345");
    metadataVersionStore.save(metadataVersion);
    metadataVersion.setName("newVersion");
    metadataVersionStore.update(metadataVersion);
    assertNotNull(metadataVersionStore.getVersionByName("newVersion"));
    metadataVersionStore.delete(metadataVersion);
}
Also used : MetadataVersion(org.hisp.dhis.metadata.version.MetadataVersion) DhisSpringTest(org.hisp.dhis.DhisSpringTest) Test(org.junit.Test)

Example 25 with MetadataVersion

use of org.hisp.dhis.metadata.version.MetadataVersion in project dhis2-core by dhis2.

the class HibernateMetadataVersionStoreTest method testGetVersionByKey.

@Test
public void testGetVersionByKey() throws Exception {
    MetadataVersion metadataVersion = new MetadataVersion("version1", VersionType.ATOMIC);
    metadataVersion.setHashCode("12345");
    metadataVersionStore.save(metadataVersion);
    assertEquals(metadataVersion, metadataVersionStore.getVersionByKey(metadataVersionStore.getCurrentVersion().getId()));
    int nonExistingId = 9999;
    assertNull(metadataVersionStore.getVersionByKey(nonExistingId));
    metadataVersionStore.delete(metadataVersion);
}
Also used : MetadataVersion(org.hisp.dhis.metadata.version.MetadataVersion) DhisSpringTest(org.hisp.dhis.DhisSpringTest) Test(org.junit.Test)

Aggregations

MetadataVersion (org.hisp.dhis.metadata.version.MetadataVersion)53 DhisSpringTest (org.hisp.dhis.DhisSpringTest)31 Test (org.junit.Test)31 IntegrationTest (org.hisp.dhis.IntegrationTest)15 Date (java.util.Date)14 ArrayList (java.util.ArrayList)12 AvailabilityStatus (org.hisp.dhis.dxf2.synch.AvailabilityStatus)12 MetadataVersionServiceException (org.hisp.dhis.dxf2.metadata.version.exception.MetadataVersionServiceException)10 DhisHttpResponse (org.hisp.dhis.system.util.DhisHttpResponse)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)6 MetadataRetryContext (org.hisp.dhis.dxf2.metadata.tasks.MetadataRetryContext)6 IOException (java.io.IOException)5 MetadataSyncServiceException (org.hisp.dhis.dxf2.metadata.sync.exception.MetadataSyncServiceException)5 HttpResponse (org.apache.http.HttpResponse)4 ComplexNode (org.hisp.dhis.node.types.ComplexNode)3 RootNode (org.hisp.dhis.node.types.RootNode)3 BadRequestException (org.hisp.dhis.webapi.controller.exception.BadRequestException)3 MetadataVersionException (org.hisp.dhis.webapi.controller.exception.MetadataVersionException)3 Before (org.junit.Before)3