Star Trek The Next Generation: Encounter at Farpoint

The new U.S.S. Enterprise-D and its crew set out "to boldly go where no one has gone before." 
Their first mission of the Galaxy-class starship U.S.S. Enterprise-D is to explore the mystery surrounding the creation of the Farpoint Station located on planet Deneb IV. While trying to negotiate a friendly agreement for Starfleet to use this energy-powered base, Captain Picard and his crew also attempt to discover how the Bandi inhabitants of Deneb IV built the station. 
En route to Farpoint, Captain Picard and his crew first meet "Q." The mysterious and powerful being denounces the human race as barbarians and challenges the crew of the Enterprise to disprove his belief. If Picard and his crew are not persuasive in their arguments, they will be sentenced to death. 
Picard defends himself and mankind by explaining that, unlike Q, humans have learned not to prosecute and judge things they don't understand. Hearing the words "prosecute" and "judge," Q announces that he knows humans all too well. He leaves the Enterprise in a blinding flash, stating that "preparations" must be made. 
After separating the saucer to protect the families on board, Picard stays behind to face Q. Suddenly, the ship begins shaking as it did when Q first appeared, and after a bright flash of light, Picard, Data, Troi and Tasha find themselves in a 21st century courtroom. When the bailiff announces the judge, the crew is shocked to find Q sitting on the bench! 
Picard convinces Q that the upcoming mission at Farpoint will be the perfect opportunity to prove his point. Q accepts Captain Picard's proposal but gives him only 24 hours and a reminder that failing this test will mean death for the Enterprise crew. 
While docked at Farpoint, Picard is introduced to his new first officer, Commander Riker, and the rest of his crew. As they begin to investigate the station, they are startled by the seemingly magical qualities of the planet where one's wish becomes reality. 
While the away team searches through tunnels beneath the Farpoint station, an unidentified ship begins firing on the old Bandi city, causing heavy damage and numerous casualties. As it turns out, the ship is a living alien being who is attacking the city because the people of Deneb IV have captured its mate. 
Not only have the Bandi been holding the being against its will, but they have used its energy source, which converts energy into matter, to create the Farpoint station and its magical qualities. 
After assisting the reunion of the estranged aliens, the crew learns that it has passed Q's test. Relieved, they head off for their next mission.