))
			})
		})

		Context("when the user provides valid JSON with the -p flag", func() {
			It("updates the user provided service specified", func() {
				runCommand("-p", `{"foo":"bar"}`, "-l", "syslog://example.com", "service-name")

				Expect(requirementsFactory.ServiceInstanceName).To(Equal("service-name"))
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Updating user provided service", "service-name", "my-org", "my-space", "my-user"},
					[]string{"OK"},
					[]string{"TIP"},
				))

				Expect(serviceRepo.UpdateArgsForCall(0).Name).To(Equal("service-name"))
				Expect(serviceRepo.UpdateArgsForCall(0).Params).To(Equal(map[string]interface{}{"foo": "bar"}))
				Expect(serviceRepo.UpdateArgsForCall(0).SysLogDrainUrl).To(Equal("syslog://example.com"))
			})
		})

		Context("when the user provides invalid JSON with the -p flag", func() {
			It("tells the user the JSON is invalid", func() {
				runCommand("-p", `{"foo":"ba WHOOPS OH MY HOW DID THIS GET HERE???`, "service-name")

				Expect(serviceRepo.UpdateCallCount()).To(Equal(0))

				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"FAILED"},
					[]string{"JSON is invalid"},
				))
				))
			})
		})

		Context("when the user provides valid single-quoted JSON with the -p flag", func() {
			It("updates the user provided service specified", func() {
				runCommand("-p", `'{"foo":"bar"}'`, "-l", "syslog://example.com", "service-name")

				Expect(requirementsFactory.ServiceInstanceName).To(Equal("service-name"))
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Updating user provided service", "service-name", "my-org", "my-space", "my-user"},
					[]string{"OK"},
					[]string{"TIP"},
				))

				Expect(serviceRepo.UpdateArgsForCall(0).Name).To(Equal("service-name"))
				Expect(serviceRepo.UpdateArgsForCall(0).Params).To(Equal(map[string]interface{}{"foo": "bar"}))
				Expect(serviceRepo.UpdateArgsForCall(0).SysLogDrainUrl).To(Equal("syslog://example.com"))
			})
		})

		Context("when the user provides valid double-quoted JSON with the -p flag", func() {
			It("updates the user provided service specified", func() {
				runCommand("-p", `"{"foo":"bar"}"`, "-l", "syslog://example.com", "service-name")

				Expect(requirementsFactory.ServiceInstanceName).To(Equal("service-name"))
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Updating user provided service", "service-name", "my-org", "my-space", "my-user"},
					[]string{"OK"},
					[]string{"TIP"},
				))
				serviceInstance.Name = "service-instance"
				serviceInstance.Params = map[string]interface{}{}
				serviceInstanceRequirement.GetServiceInstanceReturns(serviceInstance)
			})

			It("tells the user it is updating the user provided service", func() {
				cmd.Execute(flagContext)
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Updating user provided service service-instance in org"},
				))
			})

			It("tries to update the service instance", func() {
				cmd.Execute(flagContext)
				Expect(serviceInstanceRepo.UpdateCallCount()).To(Equal(1))
				Expect(serviceInstanceRepo.UpdateArgsForCall(0)).To(Equal(serviceInstance.ServiceInstanceFields))
			})

			It("tells the user no changes were made", func() {
				cmd.Execute(flagContext)
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"No flags specified. No changes were made."},
				))
			})

			Context("when the -p flag is passed with inline JSON", func() {
				BeforeEach(func() {
					flagContext.Parse("service-instance", "-p", `"{"some":"json"}"`)
				})

				It("tries to update the user provided service instance with the credentials", func() {