@Test(expected = ValidationException.class) public void setPropertyValueShouldThrowValidationExceptionWhenPropertyIsNotAllowedToSetOnContext() throws ValidationException { // given String unobfuscatedValue = "some value"; PropertyEntity propertyMock = mock(PropertyEntity.class); Mockito.when(resourceContextMock.getPropertyForDescriptor(propertyDescriptorId)).thenReturn(propertyMock); Mockito.when(propertyValidationServiceMock.canPropertyValueBeSetOnContext(Mockito.any(PropertyDescriptorEntity.class), Mockito.any(ContextDependency.class))).thenReturn(false); //when service.setPropertyValue(resourceContextMock, propertyDescriptorId, unobfuscatedValue); }
@Test public void setPropertyValueShouldSetValueAndCommentToPropertyInContext() throws ValidationException { // given String unobfuscatedValue = "some value"; PropertyEntity propertyMock = mock(PropertyEntity.class); Mockito.when(resourceContextMock.getPropertyForDescriptor(propertyDescriptorId)).thenReturn(propertyMock); Mockito.when(propertyValidationServiceMock.canPropertyValueBeSetOnContext(Mockito.any(PropertyDescriptorEntity.class), Mockito.any(ContextDependency.class))).thenReturn(true); //when service.setPropertyValue(resourceContextMock, propertyDescriptorId, unobfuscatedValue); // then Mockito.verify(propertyMock).setValue(unobfuscatedValue); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndNodeResourceTypeOnDomainContextShouldReturnFalse() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResourceType, ContextNames.DOMAIN.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isFalse(); }
@Test public void canPropertyValueBeSetOnContextForOtherThanHostNamePropertyAndNodeResourceOnDomainContextShouldReturnFalse() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResource, ContextNames.DOMAIN.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isFalse(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndOtherThanNodeResourceTypeOnDomainContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResourceType, ContextNames.DOMAIN.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForOtherThanHostNamePropertyAndOtherThanNodeResourceOnEnvContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResource, ContextNames.ENV.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndOtherThanNodeResourceOnGlobalContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResource, ContextNames.GLOBAL.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForOtherThanHostNamePropertyAndOtherThanNodeResourceOnGlobalContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResource, ContextNames.GLOBAL.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndNodeResourceOnEnvContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResource, ContextNames.ENV.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForOtherThanHostNamePropertyAndNodeResourceOnEnvContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResource, ContextNames.ENV.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndOtherThanNodeResourceOnEnvContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResource, ContextNames.ENV.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndNodeResourceTypeOnEnvContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResourceType, ContextNames.ENV.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndOtherThanNodeResourceTypeOnGlobalContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResourceType, ContextNames.GLOBAL.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndNodeResourceOnDomainContextShouldReturnFalse() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResource, ContextNames.DOMAIN.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isFalse(); }
@Test public void canPropertyValueBeSetOnContextForOtherThanHostNamePropertyAndOtherThanNodeResourceOnDomainContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResource, ContextNames.DOMAIN.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndNodeResourceOnGlobalContextShouldReturnFalse() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResource, ContextNames.GLOBAL.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isFalse(); }
@Test public void canPropertyValueBeSetOnContextForOtherThanHostNamePropertyAndNodeResourceOnGlobalContextShouldReturnFalse() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(nodeResource, ContextNames.GLOBAL.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isFalse(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndOtherThanNodeResourceTypeOnEnvContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(otherThanNodeResourceType, ContextNames.ENV.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndOtherContextDependencyResourceOnGlobalContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(new ResourceRelationContextEntity(), ContextNames.GLOBAL.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }
@Test public void canPropertyValueBeSetOnContextForHostNamePropertyAndOtherContextDependencyResourceOnEnvContextShouldReturnTrue() { // given ContextDependency<ResourceEntity> nodeResourceDependency = createFor(new ResourceRelationContextEntity(), ContextNames.ENV.name()); // when boolean b = propertyValidationService.canPropertyValueBeSetOnContext(hostNameProperty, nodeResourceDependency); // then assertThat(b).isTrue(); }