Three months after Congress refused to fully fund President Trump’s border wall, the administration’s plan to find the money itself, including by declaring a national emergency, faces its first courtroom test on Friday.

U.S. District Judge Haywood Gilliam Jr. in Oakland, Calif., will hear arguments on motions by separate groups of plaintiffs to temporarily block any wall construction on the grounds that Trump’s financing methods — transferring funds from Pentagon and Treasury Department programs never meant for such a barrier — are both unconstitutional and illegal.

The hearing is the first of what are expected to be many tests of one of the most controversial decisions made by a U.S. president in modern times: to bypass the normal appropriations process in a quest for $5.7 billion in wall construction money. Trump acted after Congress explicitly rejected his demand and appropriated only $1.375 billion, a decision that led to a 35-day government shutdown in December and January.

The plaintiffs in the Northern District of California include the state of California and 18 other states, among them Maryland and Virginia, along with the Sierra Club and the Southern Border Communities Coalition, which is represented by the American Civil Liberties Union.

To justify a temporary injunction, Gilliam will have to be convinced that the plaintiffs are likely to prevail on the merits after further proceedings and that allowing construction to go forward in the meantime will cause imminent harm.

Whatever Gilliam, who was appointed by President Barack Obama, decides will not end the controversy.

Trump’s actions have led to at least seven lawsuits in three different federal courts. One of the cases was brought by the House of Representatives in Washington. In that case, a Trump appointee, U.S. District Judge Trevor McFadden, has scheduled his own hearing on an injunction for May 23.

Whichever side loses is likely to appeal.

The cases are part of a much broader multi-front struggle underway since Trump took office, involving some of the same litigants challenging virtually his entire immigration agenda as well as his efforts to eliminate or delay hundreds of environmental regulations. They’ve had considerable success in both categories.

In the border-wall case set for Friday, each side has framed the issues and the events leading to them in starkly different terms.

In pre-hearing briefs, the plaintiffs allege, in part, a violation by Trump of Congress’s constitutional power of the purse — accomplished, they said, by misusing a host of laws to shift to wall construction money that was intended for other purposes.

Congress “unequivocally rejected the president’s requested appropriation for a border wall, only for the president to then order the diversion of federal funds from other sources toward the very project that Congress rejected,” the states say.

The states focus heavily on the tumult of February and as proof that Trump made an end-run around Congress, cite his statement that, “if we don’t get a fair deal from Congress . . . I will use the powers afforded me” to finance the wall.

“In his own public statements,” says the brief of California and other states, Trump “made clear that his emergency declaration was triggered by his inability to secure funding for the border wall from Congress rather than an actual emergency at the border.”

Department of Justice lawyers play down the process leading up to Trump’s actions and focus on his official proclamations about the “crisis” at the border rather than on his off-the-cuff comments.

“The history of negotiations between the President and Congress . . . is irrelevant,” the government argues. The administration has “invoked valid statutes” to accomplish the president’s ends, the government’s brief says, declaring that there is no constitutional issue.

Had Congress wanted to foreclose on any further spending on the wall, it could have said so explicitly through a rider, such as the Hyde amendment, which bars federal spending on abortion, the government argues.

In the absence of such a prohibition, the government says, Congress’s refusal to include all the money Trump demanded for the wall in the Department of Homeland Security appropriation in February still leaves room for the administration to dip into other pots of appropriated funds, notably at the Pentagon, to close the gap.

The Justice Department describes these transfers as military decisions in which the courts should play no role.

“Preventing the construction of border barriers” by the court would “harm the Government’s weighty interest in border security and enforcement of the immigration laws,” the Justice Department says.

All of the funding sources specified by the administration permit repurposing for certain needs, like “unforeseen” military necessities. Whether wall-building qualifies as one of those needs is the big statutory question in all the cases.

The litigation over the wall has long been billed as a test of the president’s dramatic national emergency claim, which has been attacked by critics as manufactured by Trump. But three months after his declaration, the administration has not used the Department of Defense emergency construction authority available for military construction projects that require “the use of the armed forces” and are “necessary to support such use.”

The Justice Department is arguing that it’s not at issue, at least for the moment. The Sierra Club and the ACLU are nonetheless challenging the legitimacy of the emergency declaration because the administration has identified it as a likely means of obtaining money for the wall. The plaintiffs argue that there is no emergency and no legitimate use of the armed forces for the wall.

The case is complicated further by uncertainty about which money is going where. As late as Monday, the Defense Department was still filing declarations with the court seeking to explain.

The Pentagon has said in documents it will shift some $1.5 billion from programs including a nuclear intercontinental ballistic missile system and a plane that provides surveillance and communications to fighter jets while they are airborne. That’s on top of the reprogramming of about $1 billion in Army personnel money and $3.6 billion in military construction projects the Pentagon intends to delay.

But Gilliam has asked for more clarity on the status of funds the government plans to use.

Environmental groups are also arguing that wall construction in certain areas will significantly affect the surrounding environment, disrupting the natural habitats of wildlife and threatening their survival. For those reasons, the government must prepare an environmental-impact statement before commencing construction, they said.

But the government argues that a 1996 law gives it the authority to build border barriers and to waive “all legal requirements” necessary to get the job done.

Dan Lamothe contributed to this story.