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