Merge pull request #107 from bsinno/complete-rep-tests

Complete repository tests
This commit is contained in:
Kai Zimmermann
2016-03-30 11:38:44 +02:00
105 changed files with 2375 additions and 2662 deletions

View File

@@ -169,7 +169,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
artifactManagement
.loadLocalArtifactBinary((LocalArtifact) softwareManagement
.findSoftwareModuleWithDetails(sm.getId()).getArtifacts().get(0))
.getFileInputStream()));
.getFileInputStream()));
// hashes
assertThat(artifactManagement.findLocalArtifactByFilename("origFilename").get(0).getSha1Hash())
@@ -773,12 +773,12 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
.andExpect(jsonPath("[2].createdBy", equalTo("uploadTester")))
.andExpect(jsonPath("[2].createdAt", not(equalTo(0)))).andReturn();
final SoftwareModule osCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name1", "version1")
.get(0);
final SoftwareModule jvmCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name2", "version1")
.get(0);
final SoftwareModule ahCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name3", "version1")
.get(0);
final SoftwareModule osCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name1", "version1",
osType);
final SoftwareModule jvmCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name2", "version1",
runtimeType);
final SoftwareModule ahCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name3", "version1",
appType);
assertThat(
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
@@ -930,8 +930,10 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
final SoftwareModuleMetadata metaKey1 = softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey1));
final SoftwareModuleMetadata metaKey2 = softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey2));
final SoftwareModuleMetadata metaKey1 = softwareManagement
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey1));
final SoftwareModuleMetadata metaKey2 = softwareManagement
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey2));
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
@@ -957,7 +959,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
final SoftwareModuleMetadata assertDS = softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey));
final SoftwareModuleMetadata assertDS = softwareManagement
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
}
@@ -976,7 +979,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
try {
softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey));
softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
fail("expected EntityNotFoundException but didn't throw");
} catch (final EntityNotFoundException e) {
// ok as expected

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.rest.resource.model;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
@@ -23,10 +24,14 @@ import ru.yandex.qatools.allure.annotations.Stories;
@Stories("Paged List Handling")
public class PagedListTest {
@Test(expected = NullPointerException.class)
@Test
@Description("Ensures that a null payload entitiy throws an exception.")
public void createListWithNullContentThrowsException() {
new PagedList<>(null, 0);
try {
new PagedList<>(null, 0);
fail("as content is null");
} catch (final NullPointerException e) {
}
}
@Test