@Before public void setupMocks() { validator.dataManager = mock(DataManager.class); when(validator.dataManager.fetchIdsByPropertyValue(Connection.class, "name", "Existing")) .thenReturn(new HashSet<>(Arrays.asList("same"))); when(validator.dataManager.fetchIdsByPropertyValue(Integration.class, "name", "Existing")) .thenReturn(new HashSet<>(Arrays.asList("deleted"))); when(validator.dataManager.fetch(Integration.class, "deleted")) .thenReturn(new Integration.Builder().name("Existing").id("deleted").isDeleted(true).build()); }
@Test public void testTrimming() throws IOException { final SortedSet<String> tags = new TreeSet<>(); tags.add(""); tags.add(" tag"); tags.add("\tTaggy McTagface\t"); final Integration original = new Integration.Builder() .id("test") .name(" some-name\t").description("") .tags(tags) .desiredStatus(IntegrationDeploymentState.Draft) .build(); final Integration created = Json.mapper().readValue(Json.mapper().writeValueAsBytes(original), Integration.class); assertThat(created.getName()).isEqualTo("some-name"); assertThat(created.getDescription()).isNotPresent(); assertThat(created.getTags()).containsExactly("Taggy McTagface", "tag"); } }
@Parameters public static Iterable<Object[]> parameters() { final Connection existingNameNoId = new Connection.Builder().name("Existing").build(); final Connection existingNameWithSameId = new Connection.Builder().name("Existing").id("same").build(); final Connection existingNameWithDifferentId = new Connection.Builder().name("Existing").id("different") .build(); final Connection uniqueNameNoId = new Connection.Builder().name("Unique").build(); final Integration existingButDeleted = new Integration.Builder().name("Existing").id("different").build(); return Arrays.asList(// new Object[] {existingNameNoId, false}, // new Object[] {existingNameWithSameId, true}, // new Object[] {existingNameWithDifferentId, false}, // new Object[] {uniqueNameNoId, true}, // new Object[] {existingButDeleted, true}// ); } }
protected final Integration newIntegration() { return new Integration.Builder() .id("test-integration") .name("Test Integration") .description("This is a test integration!") .steps(createSteps()) .build(); }
private static Integration newIntegration(List<Step> steps) { return new Integration.Builder() .id("test") .name("test") .steps(steps) .build(); } }