# Applying Dirichlet and Neumann boundary conditions seem to ignore Neumann boundary conditions

NDSolveValue[{-\!$$\*SubsuperscriptBox[\(\[Del]$$, $${x, y}$$, $$2$$]$$u[x, y]$$\) ==
NeumannValue[1., x == 5],
DirichletCondition[
u[x, y] ==
Piecewise[{{x, y == -1 || y == 1}, {x, x == 1 || x == -1}}],
True]}, u, {x, y} \[Element]
mesh];
Plot3D[%[x, y], {x, y} \[Element] mesh]


From the code above resulting in this plot:

Where as my mesh looks like this:

What I expected from the plot is that by setting the Neumann value to 1 on the edges, I would get an inclined plane (with a square hole). I suspect the Dirichlet condition is overriding and setting 0 everywhere on the boundary.

The wrong part of your code is :

DirichletCondition[
u[x, y] == Piecewise[{{x, y==-1 || y==1}, {x, x==1 || x==-1}}]
,True]


which should be something like :

DirichletCondition[
u[x, y] == x
, (-1.1 < x < 1.1) && (-1.1 < y < 1.1)]


The first argument of DirichletCondition specifies the value at the boundary. The second argument specifies where to apply the value. In fact it suffices to give a domain that contains the related boundary (and not the others boundaries).

By the way I have cleaned your code so that it becomes friendly in the StackExchange context :

<< NDSolveFEM
region1 = Rectangle[{-5, -5}, {5, 5}];
region2 = Rectangle[{-1, -1}, {1, 1}];
region = RegionDifference[region1, region2];
(*RegionPlot[region,ImageSize\[Rule]200]*)

mesh = ToElementMesh[region, "MaxBoundaryCellMeasure" -> 0.05];
(*Show[mesh["Wireframe"] ,ImageSize\[Rule]200]*)

NDSolveValue[{-Laplacian[u[x, y], {x, y}] == NeumannValue[1., x == 5],
DirichletCondition[
u[x, y] == x, (-1.1 < x < 1.1) && (-1.1 < y < 1.1)]}
, u
, Element[{x, y}, mesh]];
Plot3D[%[x, y], Element[{x, y}, mesh]]