@Test public void testRoundTrip() throws Exception { RegistryPackageWebConverter rpwConverter = new RegistryPackageWebConverter(); RegistryPackageType testRegistryPackage = getTestRegistryPackage(); Map<String, Object> testRegistryPackageMap = rpwConverter.convert(testRegistryPackage); RegistryPackageTypeConverter rptConverter = new RegistryPackageTypeConverter(); Optional<RegistryPackageType> optionalRegistryPackage = rptConverter.convert(testRegistryPackageMap); RegistryPackageType convertedTestRegistryPackage = optionalRegistryPackage.get(); assertThat( testRegistryPackage.getObjectType(), is(equalTo(convertedTestRegistryPackage.getObjectType()))); assertThat(testRegistryPackage.getId(), is(equalTo(convertedTestRegistryPackage.getId()))); assertThat(testRegistryPackage.getHome(), is(equalTo(convertedTestRegistryPackage.getHome()))); assertThat( testRegistryPackage.getExternalIdentifier(), is(equalTo(convertedTestRegistryPackage.getExternalIdentifier()))); assertThat( (testRegistryPackage).getRegistryObjectList().getIdentifiable().size(), is( equalTo( (convertedTestRegistryPackage).getRegistryObjectList().getIdentifiable().size()))); assertThat(testRegistryPackage, is(equalTo(convertedTestRegistryPackage))); }
@Test public void testEmptyRegistryPackage() throws Exception { Map<String, Object> emptyRegistryMap = new HashMap<>(); RegistryPackageTypeConverter rptConverter = new RegistryPackageTypeConverter(); Optional<RegistryPackageType> optionalRegistryPackage = rptConverter.convert(emptyRegistryMap); RegistryPackageType registryPackage = optionalRegistryPackage.orElse(null); assertThat(registryPackage, nullValue()); }