Skip to content

Commit

Permalink
Merge pull request #321 from liimaorg/bugfix_np_on_rest
Browse files Browse the repository at this point in the history
Added mssing value, corrected tests
  • Loading branch information
yvespp authored Jan 17, 2018
2 parents 9c140b6 + fb2f373 commit 68aac28
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* To change this license header, choose License Headers in Project Properties. To change this template file,
* choose Tools | Templates and open the template in the editor.
*/

package ch.puzzle.itc.mobiliar.business.resourcerelation.boundary;

import java.util.*;
Expand All @@ -33,7 +28,6 @@
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceException;
import javax.persistence.TypedQuery;

import ch.puzzle.itc.mobiliar.business.foreignable.control.ForeignableService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public Response addRelation(@PathParam("slaveResourceGroupName") String slaveGro
}
try {
relationEditor.addResourceRelationForSpecificRelease(resourceGroupName, slaveGroupName,
resourceType.toLowerCase().equals("provided"), null, null, releaseName, ForeignableOwner.getSystemOwner());
resourceType.toLowerCase().equals("provided"), null, resourceType, releaseName, ForeignableOwner.getSystemOwner());
} catch (ResourceNotFoundException | ElementAlreadyExistsException | ValidationException e) {
return Response.status(BAD_REQUEST).entity(new ExceptionDto(e.getMessage())).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void shouldInvokeRelationEditorWithRightArgumentsForConsumedRelations() t
Response response = rest.addRelation(slaveResourceGroupName);

// then
verify(relationEditorMock, times(1)).addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, false, null, null, rest.releaseName, ForeignableOwner.getSystemOwner());
verify(relationEditorMock, times(1)).addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, false, null, rest.resourceType, rest.releaseName, ForeignableOwner.getSystemOwner());
assertEquals(CREATED.getStatusCode(), response.getStatus());
}

Expand All @@ -120,7 +120,7 @@ public void shouldInvokeResourceRelationBoundaryAndRelationEditorWithRightArgume
Response response = rest.addRelation(slaveResourceGroupName);

// then
verify(relationEditorMock, times(1)).addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, true, null, null, rest.releaseName, ForeignableOwner.getSystemOwner());
verify(relationEditorMock, times(1)).addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, true, null, rest.resourceType, rest.releaseName, ForeignableOwner.getSystemOwner());
assertEquals(CREATED.getStatusCode(), response.getStatus());
}

Expand All @@ -133,13 +133,13 @@ public void shouldInvokeResourceRelationBoundaryAndRelationEditorWithRightArgume
String slaveResourceGroupName = "Slave";

doThrow(new ValidationException("Resource is already provided by another ResourceGroup")).when(relationEditorMock)
.addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, true, null, null, rest.releaseName, ForeignableOwner.getSystemOwner());
.addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, true, null, rest.resourceType, rest.releaseName, ForeignableOwner.getSystemOwner());

// when
Response response = rest.addRelation(slaveResourceGroupName);

// then
verify(relationEditorMock, times(1)).addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, true, null, null, rest.releaseName, ForeignableOwner.getSystemOwner());
verify(relationEditorMock, times(1)).addResourceRelationForSpecificRelease(rest.resourceGroupName, slaveResourceGroupName, true, null, rest.resourceType, rest.releaseName, ForeignableOwner.getSystemOwner());
assertEquals(BAD_REQUEST.getStatusCode(), response.getStatus());
}

Expand Down

0 comments on commit 68aac28

Please sign in to comment.